/
index.html
44 lines (42 loc) · 1.26 KB
/
index.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css"/>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
// Jquery plugin for quick Comet long polling connections from ismasan (http://gist.github.com/229343)
(function($){
$.comet = function(url, success_callback, error_callback){
error_callback = error_callback || function(a,b,c){alert('Error '+b)};
$.ajax({
type: "GET",
dataType: 'html',
url: url,
success: function(data){
success_callback(data);
$.comet(url, success_callback, error_callback);
},
error: function(a,b,c){
error_callback(a,b,c);
$.comet(url, success_callback, error_callback);
},
ifModified: true
});
}
})(jQuery);
$(function(){
$.comet('/watch',
function(data){
$('#content').prepend(data)
},
function(data){
$('#errors').html(data);
});
});
</script>
<title>node chat</title>
</head>
<body>
<div id="errors">No errors</div>
<div id="content">No content</div>
</body>
</html>