responseXML返回一个空值

本文记录了在使用Ajax的XMLHttpRequest对象时遇到responseXML为空的问题及解决过程。问题出现在URL变量赋值不准确,导致请求未能正确返回XML数据。通过修正URL,成功获取到了预期响应。

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

 

ContractedBlock.gifExpandedBlockStart.gif代码
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变量赋值错误

正确的代码应该为:

 

ContractedBlock.gifExpandedBlockStart.gif代码
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);

 

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

转载于:https://www.cnblogs.com/hantan2008/archive/2010/06/10/1755524.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值