Tuesday, October 30, 2012

Re: django-ajax giving 403



On Tue, Oct 30, 2012 at 1:03 PM, Chris Pagnutti <chris.pagnutti@gmail.com> wrote:
Hi.  I'm trying to make some AJAX calls using django-ajax https://github.com/joestump/django-ajax

But when I make the call, Chrome's console gives POST http://127.0.0.1:8000/ajax/my_app/my_ajax_view.json 403 (FORBIDDEN)
If I visit the url directly in my browser, I get {"data":{"message":"Invalid HTTP method used.","code":400},"success":false}

Reading the docs, it seems likely that the problem may be with related to not explicitly passing the csrf token in my jquery .ajax() call. But the django-ajax docs/instructions don't mention anything about this, and I kinda figured the whole point of django-ajax is to simplify these matters.

Anyone use django-ajax that can help? What do most django developers use for ajax? I've checked out Dajax, but I find it a bit much, yet I'm willing to give it, or some other package another try.

I used dajaxice  successfully (it is fearly simple) in a project that updates a google map with markers every time you move the map. It worked just fine. As Tom said my views also returned JSON. Regarding de CSRF token you only need to include the CSRF tag at the view tamplate and that's mainly it.

Check this example out :


 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eTD4Xw3RQxUJ.
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.



--
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

--
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