现在的位置: 首页 > 综合 > 正文

responseXML返回一个空值

2012年12月17日 ⁄ 综合 ⁄ 共 686字 ⁄ 字号 评论关闭

今天在联系Ajax的联系时,通过XMLHttpRequest对象的时候,返回里面的XMLHttpRequest的属性responseXML是空值,仔细查看代码

 

代码

CreteXmlhttp();
var url = "http://localhost:4496/SumIt.asmx";
var queryString = creatQueryString();
xmlHttp.open(
"POST",url,true)
xmlHttp.onreadystatechange
= handleStateChange;
xmlHttp.setRequestHeader(
"Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(queryString);

 

 

 

发现时在url变量赋值错误

正确的代码应该为:

 

代码

CreteXmlhttp();
var url = "http://localhost:4496/SumIt.asmx/Sum";
var queryString = creatQueryString();
xmlHttp.open(
"POST",url,true)
xmlHttp.onreadystatechange
= handleStateChange;
xmlHttp.setRequestHeader(
"Content-Type","application/x-www-form-urlencoded;");
xmlHttp.send(queryString);

 

应该把回调的函数直接写完整,下次一定要认真仔细,害我浪费一个小时。

抱歉!评论已关闭.