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);
        }
    });
};

posted on 2013-12-10 11:18  davidkam  阅读(194)  评论(0编辑  收藏  举报