Run jQuery after another jQuery script
Im using curl
to fetch the HTML from anothe web page and display on one of my pages:
$("document").ready(function() {
$("#content").load("curl.php .auction_list_closed");
});
Once the content i开发者_StackOverflow社区s returned I want to have another script run. How can I run another line of jQuery once the content has been loaded?
The .load()
function accepts, as the second parameter, a function which is executed once completed.
$("document").ready(function() {
$("#content").load("curl.php .auction_list_closed", function(){
startSecondScript();
});
});
add your code in the callback method
$("#content").load("curl.php .auction_list_closed", function() {
//do your stuff here.
});
You can pass a callback to the load()
method as a parameter: http://api.jquery.com/load/
$("#content").load("curl.php .auction_list_closed", function() {
// do work
});
or
$("#content").load("curl.php .auction_list_closed", myCallback);
function myCallback() {
// do work
}
Not quite sure, but i believe you can simply add an callback function. More info can be found here
For example:
$("document").ready(function() {
$("#content").load("curl.php .auction_list_closed", function() {alert("data was loaded")});
});
精彩评论