1š
Could be a couple things going on I think:
-
Specify the content type in the jQuery call, make sure it says āappliciation/jsonā (http://api.jquery.com/jQuery.ajax/) since youāre serializing assuming itās JSON but it defaults to āapplication/x-www-form-urlencodedā.
-
Your POST url expects a / at the end of its URL, and youāre posting to an endpoint without a /, which makes Django issue a redirect to the / URL. You can disable that by setting the APPEND_SLASH setting (https://docs.djangoproject.com/en/1.4/ref/settings/#append-slash), but really itās best to always call all endpoints with ā/ā at the end, so Iād say instead of posting with $.post(āapicallā, ā¦), try $.post(āapicall/ā, ā¦) and see if that helps.
Otherwise, can you post the error that you get when you do try? both from the Django console and the Javascript console in Chrome?
0š
Turns out it was wrapped in a form within the body of the HTML that I had not noticed. After removing the form wrapper it worked perfectly.
- [Answer]-Django GET or POST data will NOT bind to form
- [Answer]-South Data Migration Fails with ValueError when Function Tries to Access a Table Through a Foreign Key
- [Answer]-Purpose of "code" kwarg in ValidationError constructor
- [Answer]-Django giving [Errno 13] Permission denied