Ajax代码在IE中不起作用 [英] Ajax code doesn't works in IE
本文介绍了Ajax代码在IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script type="text/javascript">
function showState(str){
if (str.length==0){
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("state").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getState.php?cid="+str,true);
xmlhttp.send();
}
</script>
此代码在IE中不起作用,但在mozilla和chrome中很好
This code doesn't works in IE but fine in mozilla and chrome
推荐答案
您必须在xmlhttp-Object上调用send(null).只需添加
You have to call send(null) on the xmlhttp-Object. Just add
xmlhttp.send(null);
这实际上将发送请求.
这篇关于Ajax代码在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文