Ajax call from jquery works in firefox but not in IE8

I am using jquery and I am making an ajax call to a web service that returns some json data. This works fine in firefox, but for some reason not in IE.

$.ajax({
    type: "GET",
    url: "http://domain.com/Service.svc/data",
    dataType: "json",
    success: function(data) {
        //In firefox this shows the right value of test but in IE8 just "0", why?
        alert(data.d.test);
    }
});

I know the content of the response (data):

{"d":{"__type":"MyContent:#","test":888.75,"test2":592.5}}

So the warning shows 888.75 in firefox, but 0 in Internet explorer. I do not understand why this is happening?

+3
source share
5 answers

The fact is that IE had a cache: true as a standard, or at least I think it has a settings cache: false did the correct data display. In IE, it always showed old data.

$.ajax({
    type: "GET",
    url: "http://domain.com/Service.svc/data", cache: false,
    dataType: "json",
    success: function(data) {
        alert(data.d.test);
    }
});
+3
source

Try this and see what happens:

  jQuery.get("http://domain.com/Service.svc/data", 
  function(data) {
      alert(data.d.test);
  },"json");

Not sure if this will help though ...

0
source

.ajax():

data: "{}",
contentType: "application/json; charset=utf-8",

ASP.Net IE "gotchas" - jQuery. .

0

:

$.ajax({
type: "GET",
url: "http://domain.com/Service.svc/data",
dataType: "json",
success: function(jsondata) {
    data=eval("("+jsondata+")");
    alert(data.d.test);
  }
});

eval, "text/javascript" - contentType: "application/json; charset = utf-8", Lance McNearney

0

script dataType, JSON data. , , .

-1

Source: https://habr.com/ru/post/1727947/


All Articles