问题描述
- 使用xmlhttp访问webservice时,得到的xmlhttp.status=0.而且得不到返回的xml文件
-
服务器提供了
POST /LoginVerifyWebService/Login.asmx/Login HTTP/1.1
Host: 10.10.10.191
Content-Type: application/x-www-form-urlencoded
Content-Length: lengthusername=string&password=string&randomString=string
JS代码:
var xmlhttp;
function createXMLHttpRequest(){if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if(window.ActiveXObject) {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else{ alert("xmlhttp出错"); } } function btn_onclick(){ createXMLHttpRequest(); var url="http://10.10.10.191/LoginVerifyWebService/Login.asmx/Login?username=wuhl&password=Wf34566543&randomString=234234"; xmlhttp.open("GET", url, true); xmlhttp.onreadystatechange=Response; xmlhttp.send(null); } function Response(){ alert("a"+xmlhttp.readyState); if(xmlhttp.readyState==4){ alert("xmlhttp.status="+xmlhttp.status); if(xmlhttp.status==200){ alert("c"+xmlhttp.readyState); var domObj=xmlhttp.responsetext; var messageNodes=domObj.getElementsByTagName("Result"); alert(messageNodes.firstChild.nodeValue); }else{ alert("请求出错"); } } } </script>
时间: 2024-11-01 14:30:56