jQuery 帖子加载

发布于 2024-08-21 03:16:30 字数 623 浏览 2 评论 0原文

我有 2 个函数 $.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){});
    }
}

抱歉英语不好 =)

I have 2 functions $.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 =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪都笑了 2024-08-28 03:16:30

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

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

http://api.jquery.com/jQuery。发布/

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/

久而酒知 2024-08-28 03:16:30
$.post('/first/post/url', data1, function () {
    // this is executed once POST is sent
    $.post('/second/post/url', data2);
});
$.post('/first/post/url', data1, function () {
    // this is executed once POST is sent
    $.post('/second/post/url', data2);
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文