blob: 26356f5e93e450547bd8f2ceb189d852009b8c00 (
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
26
27
28
29
|
// Uses long-polling to update a div with id=#{poll}
// The gethtml route should return a new div, with the same id.
//
// Maximum update frequency is controlled by #{startdelay}
// and #{delay}, both in milliseconds.
(function( $ ) {
$.LongPoll = (function() {
return {
send : function() {
$.ajax({
'url': '@{gethtml}',
'dataType': 'html',
'success': function(data, status, jqxhr) {
$('##{poll}').replaceWith(data);
setTimeout($.LongPoll.send, #{delay});
},
});
}
}
}());
$(document).bind('ready.app', function() {
setTimeout($.LongPoll.send, #{startdelay});
});
})( jQuery );
|