欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用Ajax技術(shù)通過(guò)XMLHttpRequest對(duì)象完成首頁(yè)登錄功能

 更新時(shí)間:2014年08月21日 10:07:58   投稿:whsnow  
這篇文章主要介紹了使用Ajax技術(shù)通過(guò)XMLHttpRequest對(duì)象完成首頁(yè)登錄功能,很不錯(cuò)的嘗試,需要的朋友可以參考下

最近使用Ajax技術(shù)通過(guò)XMLHttpRequest對(duì)象完成一個(gè)首頁(yè)的登錄功能!

代碼如下:

<script type="text/javascript">

//創(chuàng)建XMLHttpRequest對(duì)象

function createXMLHttpRequest(){

if(window.XMLHttpRequest){
return xmlhttprequest=new XMLHttpRequest();
}else{
return xmlhttprequest=new ActiveXObject("Microsoft.XMLHTTP");
}

}

//登錄按鈕執(zhí)行的方法

function doStart(){

var logname=document.getElementById("loginName").value;
var logpass=document.getElementById("loginPsw").value;

var userinfo="inAccount="+logname+"&inPsw="+logpass;

var url="users/users_pswCheck.action";

xmlhttprequest=createXMLHttpRequest();

xmlhttprequest.onreadystatechange=getresultValue;

xmlhttprequest.open("post",url,true);
xmlhttprequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttprequest.send(userinfo);

}

//回調(diào)方法

function getresultValue(){
if(xmlhttprequest.readyState==4 && xmlhttprequest.status==200){

var result=xmlhttprequest.responseText;

if(result=="success"){
window.location.href="index.jsp" rel="external nofollow" ;
} else {

document.getElementById("xiaoxi").innerHTML="登錄失敗!";

}

}

}

//頁(yè)面的按鍵事件,即當(dāng)按的是回車鍵時(shí)觸發(fā)該事件

function keybutton(){

if(event.keyCode==13){ 
doStart(); 
return;
} 
}
</script>

相關(guān)文章

最新評(píng)論