I want to run:
$(".left").load("created.php");
after:
$("#placeholder").load("creat开发者_JAVA百科e.php")
I tried the following, but it didn't work:
$("#create").live("click", function() {
if($("#placeholder").load("create.php")) {
$(".left").load("created.php");
}
})
The jQuery load()
function runs asychronously. You need to use a callback function to run code after the first load completes.
The following code should suffice:
$("#create").live("click", function() {
$("#placeholder").load("create.php", function() {
$(".left").load("created.php");
});
});
Enjoy!
call the created.php
in the call back of first load
$("#placeholder").load("create.php",null,function(){
$(".left").load("created.php");
});
jquery load
Execute it in the success handler of the previous load
$("#placeholder").load("create.php", function(){
$(".left").load("created.php");
});
if($("#placeholder").load("create.php"))
this line means load create.php then return a jqxhr object which is not what you mean. use callback of load method: $("#placeholder").load("create.php", function(data){...}) Or use $.when and .then instead
精彩评论