52,782
社区成员
发帖
与我相关
我的任务
分享function callAjax(args)
{
var url="http://127.0.0.1:8080/index.jsp?arguments="
+ encodeURIComponent(args)//编码要发送的参数,而不是连url一起编码
+"&_dc="+new Date().getTime();//加时间戳防止缓存
if(window.XMLHttpRequest)
{
xmlRequest = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
xmlRequest = new ActiveXObject("Microsoft.XMLHttp");
}
if(xmlRequest)
{
//xmlRequest.open("GET",encodeURI(url),true);
//xmlRequest.open("GET",url,true); //========不需要再编码了
xmlRequest.onreadystatechange = callback;
xmlRequest.send(null);
}
} objxml.open("GET",url,false); //打开
objxml.send(); //发送
retInfo=objxml.responseText; //接收 返回文本字符串
if(objxml.readyState == 1) //初始化
{
document.getElementById("div").innerHTML ="正在加载数据...";
}
if(objxml.readyState == 4) //数据接收完毕
{ ...}