ajax的集中标准且方便调试的写法

来源:互联网 发布:大数据工程师认证考试 编辑:程序博客网 时间:2024/04/27 18:06

 $.ajax({
            type: "POST",
            dataType: "xml",
            data: { v1: "a" },
            cache: false,
            async: false,
            url: "/dll/REQUIREMENT/SMC_REQUIREMENBT_REMOVE.ashx",
            success: function (datas) {
 var r = getNodeValue(datas, 'r');
                alert(r);

            }, error: function (xhr) {

                alert("出现错误,请稍后再试:" + xhr.responseText);
            }
        });




 $.ajax({
                  type: "POST",
                  dataType: "text",
                  data: { id: "a" },
                  cache: false,
                  async: false,
                  url: "/dll/REQUIREMENT/SMC_REQUIREMENBT_REMOVE.ashx",
                  success: function (datas) {

                      var data = jQuery.parseJSON(datas);

                      for (var property in data) {
                          var bean = data[property];
                          //此处将该数组填充值                            keyValues[bean.text] = bean.content;  
                          goodsCompleteDataSource[property] = bean;
                      }

                  }, error: function (xhr) {

                      alert("出现错误,请稍后再试:" + xhr.responseText);
                  }
              });

0 0