Reputation: 4106
how to run the second function only when the first will be completed in?
$(document).ready(function() {
$("#first").load("first.php?id="+ Math.random());
$("#second").load("second.php?id="+ Math.random());
});
Upvotes: 0
Views: 144
Reputation: 129782
load()
comes with a callback parameter:
$(document).ready(function() {
$("#first").load("first.php?id="+ Math.random(), {}, function() {
$("#second").load("second.php?id="+ Math.random());
});
});
The {}
is for passing an empty object to the data
parameter.
Upvotes: 2