使用AJAX制作加载程序?状态未从数据库返回 函数main() { if(window.XMLHttpRequest) { ab=新的XMLHttpRequest; } 其他的 { ab=新的ActiveXObject(“Microsft.XMLHttp”); } ab.onreadystatechange=函数(){ 如果(ab.readyState==4&&ab.status==200) { document.getElementById(“progress”).innerHTML=ab.responseText; } } ab.open(“GET”、“querygoogle.php”); ab.send(); } 功能测试(id) { if(window.XMLHttpRequest) { xmlhttp=新的XMLHttpRequest; } 其他的 { xmlhttp=新的ActiveXObject(“Microsft.xmlhttp”); } xmlhttp.onreadystatechange=函数(){ if(xmlhttp.readyState==4&&xmlhttp.status==200) { document.getElementById(“testdiv”).innerHTML=xmlhttp.responseText; //警报(xmlhttp.responseText); } } open(“GET”,“test.php”,0); xmlhttp.send(); } 函数间隔() { main(); setInterval('test()','5000'); //test(); }
在main函数中,我调用了.php,它在db中插入数据,执行时间为4分钟。在test.php中,我只是使用SELECT查询来获取插入数据的状态。使用AJAX制作加载程序?状态未从数据库返回 函数main() { if(window.XMLHttpRequest) { ab=新的XMLHttpRequest; } 其他的 { ab=新的ActiveXObject(“Microsft.XMLHttp”); } ab.onreadystatechange=函数(){ 如果(ab.readyState==4&&ab.status==200) { document.getElementById(“progress”).innerHTML=ab.responseText; } } ab.open(“GET”、“querygoogle.php”); ab.send(); } 功能测试(id) { if(window.XMLHttpRequest) { xmlhttp=新的XMLHttpRequest; } 其他的 { xmlhttp=新的ActiveXObject(“Microsft.xmlhttp”); } xmlhttp.onreadystatechange=函数(){ if(xmlhttp.readyState==4&&xmlhttp.status==200) { document.getElementById(“testdiv”).innerHTML=xmlhttp.responseText; //警报(xmlhttp.responseText); } } open(“GET”,“test.php”,0); xmlhttp.send(); } 函数间隔() { main(); setInterval('test()','5000'); //test(); },php,javascript,Php,Javascript,在main函数中,我调用了.php,它在db中插入数据,执行时间为4分钟。在test.php中,我只是使用SELECT查询来获取插入数据的状态。 main.php运行良好,但当我以5秒的间隔运行test.php时,我没有得到任何结果,它只是继续处理 我真的不知道你在说什么,但这会让你的生活更轻松: function main() { if(window.XMLHttpRequest) { ab=new XMLHttpRequest; }
main.php运行良好,但当我以5秒的间隔运行test.php时,我没有得到任何结果,它只是继续处理 我真的不知道你在说什么,但这会让你的生活更轻松:
function main()
{
if(window.XMLHttpRequest)
{
ab=new XMLHttpRequest;
}
else
{
ab=new ActiveXObject("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();
}
很抱歉那没什么意义
function main() {
$.post("querygoogle.php", function(result) {
$(#progress).html(result);
});
}
function test(id) {
$.post("test.php?id=" + id, function(result) {
$(#testdiv).html(result);
});
}