Friday, February 4, 2011

Re: Submitting Django forms with AJAX

2011/2/4 Antônio Ribeiro <tonhogeek@gmail.com>:
> Well, I've never seen this method before "request.is_ajax()", so i went to
> documentation.
> And here what i've found:
> "Returns True if the request was made via an XMLHttpRequest, by checking
> the HTTP_X_REQUESTED_WITH header for the string 'XMLHttpRequest'."
> So I though the jQuery already sends this header automatically, but
> examining the code, I've only found that it sends the 'x-requested-with'
> maybe that's confusing Django.
> So just set this header manually and try again
>

The header jquery sets is 'X-Requested-With'. When django parses this
header, it adds it to request.META with the key
'HTTP_X_REQUESTED_WITH' (in common with all other HTTP headers).

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment