Reputation: 479
When calling specific service with ajax call IE9 returns "undefined":
$.ajax({
url: URL_PATH,
type: "get",
success: function(data) {
console.log(data);
}
});
Inspecting same code in Firefox, Chrome, IE10+, it works. I even tried adding:
contentType: "application/json; charset=utf-8",
datatype: "json",
to ajax call properties, but no luck.
Strange thing is that when I call a local JSON file, everything is okay in IE9, but when returning from local server url (information from database) that error occurs. Taking a look at response body, I got well formatted json string.
UPDATE: Also added the error catching block:
error: function(XMLHttpRequest)
{
console.log(XMLHttpRequest);
},
but no luck, it doesn't go inside the error block, it catches "success"
Upvotes: 1
Views: 2416
Reputation: 479
I found a problem. The response header of my rest service was set to charset=UTF8 and the IE couldn't recognize that while other browsers work with no problem, the correct spelling needs to be UTF-8 with a dash :) a rookie mistake. Thanks everyone for suggestions. Closing this thread now.
Upvotes: 3
Reputation: 60
there are 3 ways to solve this issue,
First one add following lines,
<!--[if lte IE 9]>
<script type='text/javascript' src='//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.0/jquery.xdomainrequest.min.js'></script>
<![endif]-->
Second one,
solve it by using dataType='jsonp' at the place of dataType='json'
Upvotes: -1