2010-03-20 43 views

回答

2

当然...

... 
success: function(data){ 
    $.ajax({..... 
} 
.... 

和之前说过,你的范围被封闭捕获。

1

你应该可以做到这一点。封闭使一切都保持在范围之内。

1

除了Matthew's answer,您还可以使用setTimeout()重复AJAX调用在预定的时间间隔,如下面的例子:

function autoUpdate() { 

    $.ajax({ 
     type: 'GET', 
     url: '/web-service/?no_cache=' + (new Date()).getTime(), 

     success: function(msg) { 
     // Add your logic here for a successful AJAX response. 
     // ... 
     // ... 

     // Relaunch the autoUpdate() function in 5 seconds 
     setTimeout(autoUpdate, 5000); 
     } 
    }); 
}