ajax请求问题
时间:2011-05-05
来源:互联网
每隔2秒发送2个ajax请求,目的是局部刷新两个图,代码如下
JScript code
运行后发现只有getJFreeCharName2起作用,getJFreeCharName根本没有起作用,如何修改上面的代码才能让这两个都运行呢?
谢谢!
JScript code
function getJFreeCharName(){ if(xmlhttp){ var url="getCharName"; var param="tag=1"; xmlhttp.open("POST",url,true); xmlhttp.setRequestHeader("Content-Length",param.length); xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlhttp.onreadystatechange=callBackFun; xmlhttp.send(param); } } //处理getJFreeCharName回调结果 function callBackFun(){ if(xmlhttp.readyState==4){ if(xmlhttp.status==200){ setTimeout("getJFreeCharName()",2000); document.getElementById("imgs").style.display=""; document.getElementById("imgs").src=document.getElementById("hidText").value + xmlhttp.responseText; } } } function getJFreeCharName2(){ if(xmlhttp){ var url="getCharName"; var param="tag=2"; xmlhttp.open("POST",url,true); xmlhttp.setRequestHeader("Content-Length",param.length); xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlhttp.onreadystatechange=callBackFun; xmlhttp.send(param); } } //处理getJFreeCharName2回调结果 function callBackFun2(){ if(xmlhttp.readyState==4){ if(xmlhttp.status==200){ setTimeout("getJFreeCharName2()",2000); document.getElementById("imgs2").style.display=""; document.getElementById("imgs2").src=document.getElementById("hidText2").value + xmlhttp.responseText; } } } getJFreeCharName(); getJFreeCharName2();
运行后发现只有getJFreeCharName2起作用,getJFreeCharName根本没有起作用,如何修改上面的代码才能让这两个都运行呢?
谢谢!
作者: zhangsc 发布时间: 2011-05-05
function getJFreeCharName2(){
if(xmlhttp){
var url="getCharName";
var param="tag=2";
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Length",param.length);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange=callBackFun2;
xmlhttp.send(param);
}
}
if(xmlhttp){
var url="getCharName";
var param="tag=2";
xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Length",param.length);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange=callBackFun2;
xmlhttp.send(param);
}
}
作者: zhangsc 发布时间: 2011-05-05
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28