[Answered ]-AJAX Callback not being called

2👍

I don’t think Django does automatic serialization for dictionaries. You’ll have to serialize them to JSON by hand.

import simplejson

# ...

return HttpResponse(simplejson.dumps(data), mimetype="application/json")

0👍

You don’t show the code that triggers the ajax_call function. If it’s as part of the onclick event for a submit button, or the onsubmit event for a form, the usual cause is that you’ve forgotten to prevent the form from submitting normally – so the page refreshes and the Ajax call is lost.

Use event.preventDefault() in your event handler to fix this.

Leave a comment