开发者

Using jQuery, what's the best way to set up a polling system?

During a document.ready, I call the "load_result" function outlined below:

function load_result()
{
    $.getJSON( "http://www.mywebsite.com/loadresult.php", function(data) {
        if( data == undefined )
        {
            null_count++;
            return;
        }
        console.log( data );
        开发者_开发技巧insert_result( data );
        setTimeout( "load_result", 500 );

    } );    

}

However, this works sporadically.. sometimes, it calls insert_result properly, and other times it doesn't. Any tips?


500ms seems kinda fast for a data refresh. Maybe trying raising the time and see if it is no longer sporadic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜