tags:

views:

23

answers:

1

Hi,

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());
});
+2  A: 

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.

David Hedlund