joestump / django-ajax

A simple framework for creating AJAX endpoints in Django.
http://github.com/joestump/django-ajax
BSD 3-Clause "New" or "Revised" License
260 stars 54 forks source link

BadRequest 400 Error #50

Closed fscz closed 10 years ago

fscz commented 10 years ago

Hi Joe, sorry for dropping this here, didn't know where else.

I wired your package to django and created 'site/app/endpoints.py'

with following content: def foo(request): return {"foo":"bar"}

from javascript: $.ajax( { url: '/ajax/claims/foo.json', dataType: 'json', type: 'GET', complete: function(jqXHR, textStatus) { alert("status: "+textStatus) } } );

however, i receive a code 400 (BadRequest). Does this indicate, that an url has to be set somewhere? From the readme i didn't get if or how those should be set?

dif2111 commented 10 years ago

I recently ran into this same problem. Apparently, you must use POST rather than GET for ajax requests.

fscz commented 10 years ago

Thanks. Still think that a GET however should work as well.

joestump commented 10 years ago

Correct, django-ajax doesn't support non-POST operations. We've been needing to make it more compliant with more modern AJAX operations (specifically CORS and JSONP), but haven't had the chance/time to.