52,782
社区成员
发帖
与我相关
我的任务
分享
function showData(){
var user=document.getElementById("user").value;
var url = "/get.php?user="+user;
createXMLHttpRequest();
xmlHttp.open("GET",url);
//请求状态改变事件触发handleStateChange功能
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");//如果有问题,这句可以去掉.
xmlHttp.send(null);
}
function CreateHttpRequest()
{
try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {
try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e2) {xmlHttp = false;}}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') //判断是不是Firefox浏览等
{
xmlHttp = new XMLHttpRequest();
if (xmlHttp.overrideMimeType)
{
xmlHttp.overrideMimeType('text/xml');
}
}
return xmlHttp;
}
function showData(){
var user=document.getElementById("user").value;
var url = "/get.php?user="+user;
var xmlHttp = false;
//判断浏览器
Newurl=url+"&temp="+Math.random(); //加一个随机数,要不然所你老是取到一样的结果。
xmlHttp=CreateHttpRequest();
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
message = xmlHttp.responseText; //获取XMLHTTP返回的值
document.getElementById("data").innerHTML=message;
}
}
else
{
document.getElementById("data").innerHTML="<img src='a.gif' style='margin-top:130px; margin-left:250px'>";
}
}
xmlHttp.open("get",Newurl,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(null);
}