ajax轮询

oa.comet = function (id) {
    if (oa.id == 0) oa.id = id;
    $.ajax({
        url: '/comet.asy?id=' + id, cache: false, dataType: 'json', error: function (request, status, thrown) { setTimeout(oa.comet, 8000 * oa.errTimes); oa.errTimes++; }, //出错  8秒之后自动连接服务器
        success: function (data) {
            if (data) { oa.cacheData = data; oa.cometInitData(data); oa.count = data.count; } oa.errTimes = 1; oa.comet(oa.id);
        }
    });
};

原文地址:https://www.cnblogs.com/tonykan/p/3467111.html