Question

$(document).ready(function () {
        $(".box2").load("page1.html");
    });
    $(".box2").ready(function () {
        $(".box3").load("page1.html");
    });

That's my code, I've got a few boxes all with an image and I want it so when image 1 ( page1.html) is loaded, only then the next one must load and not before the first one is loaded.

Was it helpful?

OTHER TIPS

You can set a on complete handler for the load call. You can chain the next call within that function

Example:

$( "#result" ).load( "ajax/test.html", function() {
  alert( "Load was performed." );
});

For your situation:

$(document).ready(function () {
   $(".box2").load("page1.html", function () {
      $(".box3").load("page1.html");
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top