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
45
46
47
48
49
50
51
52
53
54
55
56
| <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Comet Test</title>
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
(function($){
function handleResponse(response){
$('#content').append('<div>' + response['msg'] + '</div>');
}
var timestamp = 0;
var url = './chat_backend.php';
var noerror = true;
var ajax;
function connect() {
ajax = $.ajax(url, {
type: 'get',
data: { 'timestamp' : timestamp },
success: function(transport) {
eval('var response = '+transport);
timestamp = response['timestamp'];
handleResponse(response);
noerror = true;
},
complete: function(transport) {
(!noerror) && setTimeout(function(){ connect() }, 5000) || connect();
noerror = false;
}
});
}
function doRequest(request) {
$.ajax(url, {
type: 'get',
data: { 'msg' : request }
});
}
$('#cometForm').live('submit', function(){
doRequest($('#word').val());
$('#word').val('');
return false;
});
$(document).ready(function(){
connect();
});
})(jQuery);
</script>
<div id="content"></div>
<div style="margin: 5px 0;">
<form action="javascript:void(0);" id="cometForm" method="get">
<input id="word" name="word" type="text" value="">
<input name="submit" type="submit" value="Send">
</form></div> |
不懂JS,求解:没看明白JS是怎么连接上memcache的?
前端的JS不可能连接的上memcache的,何况本文章并不涉及memcache
我直接复制你的代码,但发现会出现ajax超时.导致返回的transport.在eval()报错..这么解决呀..
PHP.INI里设置下脚本超时时间.
怎么跟数据库做链接那?大神求解 q:546533165