Form submitted multiple times when using the “submit” callback and $.ajax to post it

后端 未结 8 1525
闹比i
闹比i 2020-12-14 17:50

I\'ve been observing some strange behavior with the following code:

$.fn.submit_to_remote = function() {
  // I use .each instead of the .submit directly so          


        
8条回答
  •  再見小時候
    2020-12-14 18:34

    Not sure about this strange behavior, but seems that unbinding the submit event will do the trick.

    So, before running the script returned by the $.ajax call, run this:

    $('.submit_to_remote').unbind("submit");
    

    That should remove previous bindings and leave just the new one.

提交回复
热议问题