我有一个在xampp上运行的脚本,当我运行这个带有警报调用的脚本时,文件会执行,但是当我运行它而没有警报时它只是坐在那里并没有返回任何内容。我做错了什么?
代码:
var xhr;
function getPlants(xhr){
尝试{
xhr = new XMLHttpRequest();
}赶上(微软){
尝试{
xhr = new ActiveXObject(“Msxml2.XMLHTTP”);
}赶上(othermicrosoft){
尝试{
xhr = new ActiveXObject(“Microsoft.XMLHTTP”);
}赶上(失败){
XHR = FALSE;
警报(“不支持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;
}
}