user1238115
user1238115

Reputation: 83

Loading an element. After that loading another element into the loaded element

i built a website where my frame, with the main menue and the banner, is always exisiting.

I created a div element, in which i can load everything i want dynamically.

But now i have a problem. If somebody clicks a link, i want to load a html document into my div-frame. When this has been done, a another html document should be loaded into a part of the new loaded html document.

The rask is now, to check when the first div element has been loaded and load something into this element.

An Example:

$("#examplelink").click(function() 
{

$("#mainsite").load("firstlowerside.html");

$("#firstlowerside_div").load("secondlowerside.html");

});

Javascript is ignoring the command line: $("#firstlowerside_div").load("secondlowerside.html") , because the "firstlowerside.html" isnt already exisiting at this thime.

Can somebody tell my how i can check is the document has been loaded into my div and start executing the second command after this?

Upvotes: 2

Views: 161

Answers (1)

Musa
Musa

Reputation: 97672

.load has a complete callback parameter you can pass a function that will fire after the content is loaded.

$("#mainsite").load("firstlowerside.html", function(){
    $("#firstlowerside_div").load("secondlowerside.html");
});

Upvotes: 6

Related Questions