简体   繁体   中英

Run a function after ajax call is completed?

I have different pages ex1.php ,ex2.php, ex3.php

All of these pages have different ajax call and they have some code in the respective success function.

I want to run a function myfunc() when i get any response in any of these ajax calls?? Is it posssible??

Can i use jquery complete???

I have only one js file which is common to all these files where i have myfunc() written

ex1.php

$.ajax()

ex2.php

$.ajax()

ex3.php

$.ajax()

test.js which is loaded in all these php file has myfunc

使用ajaxSuccess事件处理程序

$( document ).ajaxSuccess(myfunc);

You should call your myfunc on the success of the ajax call

$.ajax({
url: "ex2.php"
}).done(function() {
  myfunc()
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM