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.
精彩评论