drn5375 2016-03-10 12:59
浏览 95
已采纳

Ajax刷新div在刷新后显示旧数据

Hi there I am looking for some hints to troubleshoot a problem I am having with ajax refresh , The problem is the div shows latest info on load but when it refreshes it is showing older data . The div shows the latest tracks played on air like I say when the page loads it shows the correct tracks but after 10 seconds when it reloads It is showing older tracks .

Here is my code ...

$(document).ready(function() {
    $("#tracks").load("json.php");
    var refreshId = setInterval(function() {
        $("#tracks").fadeOut('slow').load("json.php").fadeIn('slow');
    }, 10000);
    $.ajaxSetup({ cache: false });
});

Any help figuring this problem out would be greatly appreciated

  • 写回答

2条回答 默认 最新

  • dongwu9972 2016-03-10 13:08
    关注

    This is probably caused by caching of the browser. You should explicitly turn off caching to avoid this.

    In ASP you could/should set:

    Response.CacheControl = "no-cache, no-store, must-revalidate"
    Response.Expires = -1
    

    See this topic for an excellent discussion about this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题