0

I'm sending a cross domain request using jquery ajax. I can send the request successfully, but when I get response I get syntax error in console and XML processing error.

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.");
  }
  });
});

I want to copy the response to a variable so that I can parse it and display it accordingly in a multiselect

Rudra
  • 711
  • 7
  • 13
  • 31

1 Answers1

0

Simply copy the xml response in success function in your variable and parse it.

Exactly what you are looking for:

parse xml with jquery ajax request

Community
  • 1
  • 1
vicky
  • 885
  • 1
  • 7
  • 23
  • Using JSONP. this might solve your problem: http://stackoverflow.com/questions/11736431/make-cross-domain-ajax-jsonp-request-with-jquery/11736771#11736771 – vicky Jul 17 '14 at 12:25