2011-08-11 55 views
0

我想創建它接受一個arguement像這樣一個PHP頁面:PHP腳本Arguements到AJAX自動刷新

http://localhost/page.php?topic=Foo

,然後自動從SQL數據庫提取數據,其中的話題=美孚但隨後每10秒檢查一次新數據並使用Ajax刷新DIV標籤。我試過了,沒有任何工作。任何幫助?

編輯:這是我使用的代碼:

<html> 
<head> 
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script> 
ext = <?php $_GET[feedtitle] ?> 
$(document).ready(function() { 
    $("#responsecontainer").load("response.php?ext=" + ext); 
    var refreshId = setInterval(function() { 
     $("#responsecontainer").load('response.php?ext=' + ext); 
    }, 9000); 
    $.ajaxSetup({ cache: false }); 
}); 
</script> 
</head> 
<body> 

<div id="responsecontainer"> 
</div> 
</body> 

編輯:我可以做的SQL位,它只是得到arguement到遇到問題的response.php IM。

編輯:我有新的代碼,但它仍然沒有工作:

<html> 
<head> 
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script> 

function gup(name) 
{ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
    var regexS = "[\\?&]"+name+"=([^&#]*)"; 
    var regex = new RegExp(regexS); 
    var results = regex.exec(window.location.href); 
    if(results == null) 
    return ""; 
else  
    return results[1]; 
} 

var feed = gup('f'); 

$(document).ready(function() { 
$("#responsecontainer").load("response.php?ext=" + feed); 
var refreshId = setInterval(function() { $("#responsecontainer").load('response.php? ext=' + feed); }, 9000); 
$.ajaxSetup({ cache: false }); 
}); 
</script> 
</head> 
<body> 

<div id="responsecontainer"> 
</div> 
</body> 
+0

你有什麼試過,這是壞了?你可以在這裏發佈你的嘗試嗎? – karim79

+0

以及您到目前爲止嘗試過哪些方法無效? –

+0

@karim我已更新該帖子。 –

回答