wilsonrufus
wilsonrufus

Reputation: 449

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

Upvotes: 0

Views: 284

Answers (2)

Dilantha
Dilantha

Reputation: 1634

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

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

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

Use the ajaxSuccess event handler

$( document ).ajaxSuccess(myfunc);

Upvotes: 3

Related Questions