blob: 5b704acec385ff322627f264d3e80949beace7fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Uses long-polling to update a div with a specified id,
// by polling an url, which should return a new div, with the same id.
connfails=0;
function longpoll(url, divid, cont, fail) {
$.ajax({
'url': url,
'dataType': 'html',
'success': function(data, status, jqxhr) {
$('#' + divid).replaceWith(data);
connfails=0;
cont();
},
'error': function(jqxhr, msg, e) {
connfails=connfails+1;
if (connfails > 3) {
fail();
}
else {
cont();
}
}
});
}
|