zoukankan      html  css  js  c++  java
  • responseXML返回一个空值

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

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

  • 相关阅读:
    mysql(二)数据类型
    mysql(一)
    MySQL8 安装官方示例 employees 数据库
    Elasticsearch入门
    redis入门
    git 基本使用
    vue-cli4环境变量配置和代理跨域配置
    nginx配置
    彻底搞清浏览器和服务器跨域
    File文件过滤器
  • 原文地址:https://www.cnblogs.com/hantan2008/p/1755524.html
Copyright © 2011-2022 走看看