JavaScript: Detect form submission completion

馋奶兔 提交于 2020-01-11 10:27:14

问题


I have a form in an iframe and submit it. How can I tell when the submission completes? I'm using jQuery to submit the form but don't think there's a callback:

$("#myForm").submit(); // how to attach event to submission complete?


回答1:


Submission of the form will redirect you to the next page.

But you can always try the ajax function

http://api.jquery.com/jQuery.ajax/

Adding callback is as easy as

 $.ajax({
   url: "page.php",
   success: function() {
      doWhateverYouWant();
   }
 });



回答2:


If you submit a form, it goes to the next page, so there's nothing else that executes on that page.



来源:https://stackoverflow.com/questions/5629588/javascript-detect-form-submission-completion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!