[Django]-JQuery Ajax function called twice with same data

7👍

Replace this:

$( "#todoform" ).submit(function(e)

With this:

$( "#todoform" ).unbind('submit').submit(function(e)
👤Nabeel

1👍

Probably onload() is being called twice, check all occurrences of it through your code. If you call .submit() twice, the onsubmit event is appended with the code given, not replaced.

To debug, put an alert('anything') inside sendtodo() and check if it’s really being called twice when submitting.

You can also do:

$('#todoform').removeAttr('onsubmit').submit( ...

But it would be better to find out why it’s being bound twice

👤ariel

Leave a comment