0

I am using the below code snippet to fetch data from a certain webAPI.

data.responseText works fine in FireFox but gives undefined in IE L

I have tried using data.responseJSON also but it doesn’t work in IE.

Please give me the solution to this.

Here is the code which I am using.

 $.ajax({

          type: "GET",

          url: serviceUrl,

          contentType: "application/json",

          data: "{'slid':'" + slidname + "'}",

          async: false,

          crossDomain: true,

          complete: function (data) {

          alert("hii");

         alert(data.responseText);

          }



      });
Rameez
  • 53
  • 1
  • 2
  • 10
  • In order to fully diagnose this problem it would be necessary to have version numbers (for IE and jQuery) and also the URLs of the page you are writing and the service URL it's connecting to. But I think you might be suffering from the same problem as this question: http://stackoverflow.com/questions/17550248/ajax-cross-domain-request-ie-8 (i.e. cross origin requests not working in IE8 and 9 with jQuery) – Andrew Bryant Mar 17 '15 at 15:35

1 Answers1

0

Which version of the IE? If IE9 or less, the issue could be your jQuery version - see http://jquery.com/browser-support/.

Otherwise, you could try if letting the browser do the formatting of the ajax request data helps:

$.ajax({ type: "GET", url: serviceUrl, contentType: "application/json", data:JSON.stringify( {"slid": slidname} ), async: false, crossDomain: true, complete: function (data) { alert("hii"); alert(data.responseText); } });

If this also fails, you may want to try "jsonp" as dataType for the ajax call since you have a cross-domain request.

$.ajax({ type: "GET", url: serviceUrl, contentType: "application/json", data: JSON.stringify( {"slid": slidname} ), async: false, crossDomain: true, dataType: "jsonp", complete: function (data) { alert("hii"); alert(data.responseText); } });

j0ffe
  • 621
  • 8
  • 13