function main()
{
if(window.XMLHttpRequest)
{
ab=new XMLHttpRequest;
}
else
{
ab=new ActiveXObje开发者_如何学编程ct("Microsft.XMLHttp");
}
ab.onreadystatechange=function(){
if(ab.readyState==4 && ab.status==200)
{
document.getElementById("progress").innerHTML=ab.responseText;
}
}
ab.open("GET","querygoogle.php");
ab.send();
}
function test(id)
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest;
}
else
{
xmlhttp=new ActiveXObject("Microsft.XMLHttp");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("testdiv").innerHTML=xmlhttp.responseText;
//alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET","test.php",0);
xmlhttp.send();
}
function interval()
{
main();
setInterval('test(<? echo $_SESSION['id'];?>)','5000');
//test();
}
In main function i call .php which inserts data in db and has execution time of 4 min...in test.php i am just using SELECT query to get status of the inserted data. main.php runs fine but when i run test.php with an interval of 5 secs..i don't get any result and it just keeps on processing.
I am really not sure what you are talking about, but jQuery makes your life easier:
function main() {
$.post("querygoogle.php", function(result) {
$(#progress).html(result);
});
}
function test(id) {
$.post("test.php?id=" + id, function(result) {
$(#testdiv).html(result);
});
}
精彩评论