Search code examples
jqueryjquery-load

Load multiple files into one div via JQuery .load?


I'm trying to do this:

$("#Div").click(function(){
  $("#PageContentDiv").load("file.php");
  $("#PageContentDiv").load("another.php");
});

This issue is that the second load function is replacing the first ...


Solution

  • Try using $.get() in complete callback of .load() , .append()

    $("#Div").click(function() {
      var page = $("#PageContentDiv");
      page.load("file.php", function() {
        $.get("another.php", function(html) {
          page.append(html);
        });
      });     
    });