php - Alternative to using setTimeout with AJAX? -
hey guys, there more efficient way this?
setinterval('getallwords()', 2000); function getallwords() { $.ajax({ type: "get", url: "queries.php", data: "action=all", success: function(data){ dataarray = data.split('|'); $('#words').html(''); (var = 0; < dataarray.length; i++) { if ((dataarray[i]).length > 1) { $('ul').append('<li>' + dataarray[i] + '</li>'); } } } }); }
elaboration (?)
this connect every 2 seconds database , checks updated words, there easy way implement push
request or minimise database activity?
more info:
my hosting doesn't support installing of ajax push servers , won't install 1 me
:(
if can't install push server, consider hack:
run infinite loop sends answer ajax request once there's new (while(true) { check updated words}).
in ajax code can start request , it's finished start new 1 (eg. readystate == 4 --> start new request)
Comments
Post a Comment