Skip to content

Instantly share code, notes, and snippets.

@carlosrberto
Created April 12, 2012 17:45
Show Gist options
  • Save carlosrberto/2369575 to your computer and use it in GitHub Desktop.
Save carlosrberto/2369575 to your computer and use it in GitHub Desktop.
django request.is_ajax() workaround for IE
def response_mimetype(request):
tridentEngine = 'Trident' in request.META['HTTP_USER_AGENT'] or 'MSIE' in request.META['HTTP_USER_AGENT']
if tridentEngine:
return 'text/html'
else:
return 'application/json'
<form action="?xhr=true" class="form" method="post">
...
if request.GET.get('xhr', False):
return HttpResponse( retorno_forms, mimetype=response_mimetype(request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment