2014-09-19 91 views
0

我一直在試圖讓我的三個更新同時點擊按鈕來獲取更新它將計入新的提要,通知和消息。我也嘗試過使用setInterval("getupdate()", 10000),每10秒自動更新一次,但不適用於第二和第三個div。爲什麼在第二次和第三次調用之後ajax load()不工作?

還是因爲Ajax不支持很多load()調用?

現在,我不知道該怎麼做,需要你的幫助。謝謝。

的Javascript

</script> 

function getupdate(){ 
    $('#newsfeed').load('getnewsfeed.php'); 
    $('#notify').load('getnewnoti.php'); 
    $('#message').load('getnewmessage.php'); 
} 

</script> 

HTML

<button type="button" onclick="getupdate()" class="btn btn-primary">Get Update</button> 
<div id="newsfeed"></div> 
<div id="notify"></div> 
<div id="message"></div> 
+0

你檢查了控制檯的錯誤嗎?或者檢查回覆是否有價值? – 2014-09-19 10:34:15

+0

是的,我已經檢查並且將'$('#notify')。load('getnewnoti.php')'和'$('#message')。load('getnewmessage.php')'作爲第一個,它運作良好。 – Marcus 2014-09-19 10:37:04

+1

請顯示您的網頁的其餘部分。無效的HTML(包括重複的ID或缺少的標記)將導致匹配失敗。 – 2014-09-19 10:39:33

回答

0

如果併發AJAX調用一個問題,你可以隨時加載它們的順序:

function getupdate(){ 
    $('#newsfeed').load('getnewsfeed.php', function(){ 
     $('#notify').load('getnewnoti.php', function(){ 
      $('#message').load('getnewmessage.php'); 
     }); 
    }); 
} 

如果這不幫助,我們需要看到你的頁面的其餘部分太請 :)

您還需要檢查全部三個服務器方法是否正在返回某些內容而不是錯誤。

+0

是的..這是我正在尋找和它的作品。謝謝@TrueBlueAussie – Marcus 2014-09-19 10:47:58

相關問題