今天在联系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);

 

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

相关文章:

  • 2021-12-29
  • 2022-03-05
  • 2021-10-29
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案