本文介绍了jQuery的Ajax调用在Firefox中有效,但在IE8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery,并且对返回一些json数据的web服务进行了ajax调用.这在firefox中工作完美,但由于某些原因在IE中不行.

I'm using jquery and I make a ajax call to a webservice that returns some json data. This works perfect 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 that the content of the response (data) is:

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

因此,警报在Firefox中显示为888.75,但在Internet Explorer中显示为0.我不明白为什么会这样?

So the alert shows 888.75 in firefox but 0 in internet explorer. I can't see why this is happening?

推荐答案

问题是IE具有缓存:标准为true,或者至少我认为它具有设置缓存:false可以显示正确的数据.在IE中,它总是显示旧数据.

The thing was that IE had cache: true as standard, or at least I think it has as setting cache: false made the right data show. In IE it was always showing old data.

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

这篇关于jQuery的Ajax调用在Firefox中有效,但在IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 06:16