jQuery发布加载

时间:2010-02-15 13:46:13

标签: jquery post timeout load

我有两个函数$ .post jQuery,如何在第一个$ .post加载完成后才进行第二个$ .post? 但我不能在$ .post中使用$ .post,因为第二个$ .post从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){});
    }
}

抱歉英语不好=)

2 个答案:

答案 0 :(得分:2)

你可以使用第一篇文章的回调函数:

$.post('ajax/first.html', function(data_first) {
  $.post('ajax/second.html', function(data_second) {
      $('.result').html(data_second);
  });
});

http://api.jquery.com/jQuery.post/

答案 1 :(得分:2)

$.post('/first/post/url', data1, function () {
    // this is executed once POST is sent
    $.post('/second/post/url', data2);
});