2010-02-15 4 views
1

2 개의 함수 $ .post jQuery가 있는데, 첫 번째 $ .post가 로딩 된 후에 만 ​​수행되는 두 번째 $. post를 만드는 방법은 무엇입니까? 두 번째 $의 .post 나쁜 영어에 대한jQuery posts 로딩

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

당신은 첫 번째 게시물의 콜백 기능을 사용할 수 있습니다) = $의 .post 내에서 $ .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/

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