weixin_33701294 2012-06-04 14:40 采纳率: 0%
浏览 40

IE8的长时间轮询问题

Im building an app that uses long polling technique and im running into some trouble with IE8.

so here is the simplified code that i use:

php:

 $time = time();
    while((time() - $time) < 10) {
        $data = rand(0,10);    
        // if we have new data return it
        if($data == 3 || $data == 6) {
            echo json_encode($data);
            break;
        }
            sleep(1);
        }

js:

var lpOnComplete = function(response) {
        alert(response);
        // do more processing
        lpStart();
    };

    var lpStart = function() {
        $.post('http://example.com/test', {}, lpOnComplete, 'json');
    };

    $(document).ready(lpStart);

The problems seems to be that IE8 is not waiting til the server responds but fires the next request straight after or dies after first proper response. What may cause this behavior?

  • 写回答

1条回答 默认 最新

  • weixin_33712881 2012-07-27 11:33
    关注

    This seemed to do the trick.

    $.ajaxSetup ({
       cache: false
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿