Reputation: 3790
I'm using .load()
and .show()
to dynamically load some HTML.
//load the html
$('#mydiv').load('some_url');
// Display
$('#mydiv').show();
But here I need to call a JavaScript function that only exist in the dynamic content, how can I tell if the .load()
is complete ?
Upvotes: 14
Views: 40973
Reputation: 10388
$( "#mydiv" ).load( "url", function() {
alert( "Load was performed." );
});
reference load
Upvotes: 5
Reputation: 1379
$('#mydiv').load('some_url', function(responseText, textStatus, XMLHttpRequest){
console.log("Content Loaded!");
});
Look at this
Upvotes: 2
Reputation: 1258
The load function get a callback function for complete
('#mydiv').load('some_url', function() {
alert( "Load completed." );
});
Upvotes: 7
Reputation: 78565
Use the callback for .load:
$('#mydiv').load('some_url', function() {
// This gets executed when the content is loaded
$(this).show();
});
Upvotes: 41