【问题标题】:How can I send an XML request and process it using jquery ajax and cors如何发送 XML 请求并使用 jquery ajax 和 cors 处理它
【发布时间】:2014-07-17 22:36:32
【问题描述】:

我正在使用 jquery ajax 发送跨域请求。我可以成功发送请求,但是当我收到响应时,控制台中出现语法错误和 XML 处理错误。

var xml_response="http://test.test.in:8080/RestAPI/ServiceRequestServlet?request=<xml><request><functiontype>2003</functiontype><groupzid>185</groupzid><moduleid>8</moduleid><servicetype>21</servicetype></request></xml>"

$(document).ready(function(){
  $("#dvContent").append("<ul></ul>");
  $.ajax({
    type: "GET",
    crossDomain: true,
    url: xml_response,
    dataType: 'jsonp',
    success: function(xml){

     alert("success");

  },
  error: function() {
    alert("An error occurred while processing XML file.");
  }
  });
});

我想将响应复制到一个变量,以便我可以解析它并在多选中相应地显示它

【问题讨论】:

    标签: jquery ajax cors


    【解决方案1】:

    只需将成功函数中的 xml 响应复制到变量中并解析即可。

    正是您要找的:

    parse xml with jquery ajax request

    【讨论】:

    猜你喜欢
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 2013-03-26
    • 2014-09-13
    • 1970-01-01
    • 2012-07-23
    相关资源
    最近更新 更多