I have 2 functio开发者_StackOverflow中文版ns $.post jQuery, how to make the 2nd $.post carried out only after the loading of the first $.post completely finished? But I can not use $.post within $.post because the second $.post called from flash
function play(id, file, dur, who, hname, artist, song)
{
if($.cookie('scrobb') == 'on')
{
setTimeout(function(){
$.post("/scrobbling/", { nowplaying: 1 , artist: artist, song: song, duration: dur},function(){});
}, 5000);
}
}
function songIsOver()
{
if($.cookie('scrobb') == 'on')
{
$.post("/scrobbling/", { submission: 1 , artist: bartist, song: bsong, duration: bdur},
function(data){});
}
}
Sorry for bad english =)
You could use the callback function of the first post:
$.post('ajax/first.html', function(data_first) {
$.post('ajax/second.html', function(data_second) {
$('.result').html(data_second);
});
});
http://api.jquery.com/jQuery.post/
$.post('/first/post/url', data1, function () {
// this is executed once POST is sent
$.post('/second/post/url', data2);
});
精彩评论