Ajax长轮询
HTML code:
<script type="text/javascript">
<!--
var time = 0;
var http_request=null;
function HttpRequest(){
if (window.ActiveXObject){
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest){
http_request = new XMLHttpRequest();
}
return http_request;
}
HttpRequest();
function autoSend(timestamp){
url = 'http://www.me.c/comet/back.php';
http_request.open('GET', url, false);
//http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
http_request.send('timestamp='+ timestamp +'&num='+Math.random());
// http_request.onreadystatuschange = CallBack;
var data = http_request.responseText;
var json = eval('('+ data +')');
alert(json.timestamp);
document.getElementById('content').innerHTML += '<div>'+json.msg +'</div>'
autoSend(json.timestamp);
}
function send(){
var msg = document.getElementById('msg').value;
var url = 'http://www.me.c/comet/back.php';
http_request.open('POST', url, false);
http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
http_request.send('msg='+msg+'&num='+Math.random()
相关问答:
s.com 域名下有一文件process.asp
VBScript code:
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Response.Add ......
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1&q ......
现在用的功能相当于选项卡,之前的使用js控制层的现实来识别的,函数如下
JScript code:
function showDiv(id,num)
{ for(i=1;i<=num;i++) {
var currentId="div"+i;
......
VBScript code:
Dim FoundErr,MsgErr
FoundErr = true
username=request.QueryString("userName")
password=request.QueryString("userPwd")
MsgErr = ""
if username = &qu ......