1

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 is returned I want to have another script run. How can I run another line of jQuery once the content has been loaded?

2
  • any reason why not to fetch the HTML directly? Commented Jan 3, 2011 at 16:00
  • Just out of curiosity, what is the .auction_list_closed representative of? I've not seen that syntax before. Commented Jan 4, 2011 at 13:47

4 Answers 4

4

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();
    });
});
Sign up to request clarification or add additional context in comments.

Comments

3

add your code in the callback method

$("#content").load("curl.php .auction_list_closed", function() {
  //do your stuff here.
});

Comments

2

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
}

Comments

1

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")});

});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.