$.getJSON()存在缓存问题,如果其调用的url之前曾经调用过的话,回调函数就会直接在缓存里取得想要得值,而不是进入到后台
 
在项目中遇到一个问题,在火狐下,$.getJSON();请求数据一切正常,但是在IE下面,$.getJSON();只请求一次数据,第二次根本就不发送请求了,用fiddler抓取了才知道,第二次没有发送请求,改成了post就正常了
 

解决方法如下:

1、让每次调用的URL都不一样。

方法:在参数中加一个随机数

$.getJSON("/Member/GetExercise.html", { id: $("#Wareid").val(), isBool: loop, random: Math.random() }, function (data) });

 

2、将cache设为false

$.ajax({
    type:"GET",
    url:'/Member/GetExercise.html',
    cache:false,
    dataType:"json",
    success:function (data){
        alert(data);
    }
});

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-02-17
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2022-02-09
  • 2021-08-07
  • 2021-10-27
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案