我有jquery.ajax總是向服務器請求數據。我的問題是當我點擊某個導航菜單時我無法導航它太慢了。我試圖評論成功內的方法,它工作正常,我可以很快導航,因爲沒有請求運行...任何想法如何使這項工作有請求同時運行,我可以導航到其他頁面。?。運行jquery.ajax導致在導航到其他頁面時速度減慢
更多的輸入信息非常感謝。
預先感謝您。
$(function(){
getUpdates();
});
function getUpdates(){
type: "GET",
dataType:'json',
url: "updates.php",
error: function() {
setTimeout(getUpdates, 5000);
},
success: function(data){
//do something with the data
...
...
...
getUpdates(); //call again the function
}
});
}
嘗試使用'setTimeout(getUpdates,5000);''inside'success:',而不是'getUpdates();' – ariel 2014-09-21 14:46:04