【发布时间】:2011-01-07 21:46:31
【问题描述】:
我有一个在 xampp 上运行的脚本,当我在其中运行带有警报调用的该脚本时,文件会执行,但是当我在没有警报的情况下运行它时,它只是坐在那里并且不返回任何内容。我做错了什么?
代码:
var xhr;
函数 getPlants(xhr){
尝试 {
xhr=新 XMLHttpRequest();
}catch(微软){
尝试{
xhr=new ActiveXObject("Msxml2.XMLHTTP");
}catch(其他微软){
尝试{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}捕捉(失败){
xhr=假;
alert("不支持ajax");
}
}
}
xhr.onreadystatechange=state_change;
xhr.open("GET","db_interactions.php",true);
xhr.send(null);
alert("sent");
function state_change() {
if(xhr.readyState==4 && xhr.status==200) {
alert("all systems go");
return xhr.responseText;
}
}
【问题讨论】:
-
@大全 -- 如果你一个一个删除并替换警报,它会停止对哪一个工作?
标签: javascript ajax