I am writing a webapp ( Firefox only ) that uses a lengthy survey (using jQuery ajax features) to send more or less constant updates from the server to the client. I am concerned about the consequences of leaving this regime for long periods of time, say, all day or night. The basic code skeleton is as follows:
function processResults(xml)
{
}
function fetch()
{
setTimeout(function ()
{
$.ajax({
type: 'GET',
url: 'foo/bar/baz',
dataType: 'xml',
success: function (xml)
{
processResults(xml);
fetch();
},
error: function (xhr, type, exception)
{
if (xhr.status === 0)
{
console.log('XMLHttpRequest cancelled');
}
else
{
console.debug(xhr);
fetch();
}
}
});
}, 500);
}
(Half a second of "sleep" is that the client does not clog the server, if updates return to the client quickly - usually they.)
, Firefox. , , . , Firebug fetch, , . , Firebug, 4 5 , .
, , , , Ajax . JS 1.7 "yield" , , , , .
, , ? / , 8 12 ? " ", , ?