ajax...
时间:2010-08-10 来源:ajaxchen_615
function InitAjax(){
var ajax=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){ //Mozilla 浏览器
ajax = new XMLHttpRequest();
if (ajax.overrideMimeType) {//设置MiME类别
ajax.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){ // IE浏览器
try{
ajax = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}
if(!ajax){ // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest对象实例.");
return false;
}
return ajax;
}
xmlhttp=InitAjax();
xmlhttp.open("POST","do.php?act=login",true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
var return_text=xmlhttp.responseText;
alert(return_text);
location.reload();
}
};
xmlhttp.send("u_email="+u_email+"&u_pws="+u_pws+"&hidden="+u_hidden);