主页 > 知识库 > 使用Ajax技术通过XMLHttpRequest对象完成首页登录功能

使用Ajax技术通过XMLHttpRequest对象完成首页登录功能

热门标签:科智联智能电销机器人 徐州电销卡外呼系统供应商 青海医疗智能外呼系统怎么样 上海浦东百度地图标注中心注册 襄阳外呼系统接口 老虎邮局地图标注点 百灵鸟 目标三维地图标注 外呼系统获取客户手机号

最近使用Ajax技术通过XMLHttpRequest对象完成一个首页的登录功能!

代码如下:

script type="text/javascript">

//创建XMLHttpRequest对象

function createXMLHttpRequest(){

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

}

//登录按钮执行的方法

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);

}

//回调方法

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="登录失败!";

}

}

}

//页面的按键事件,即当按的是回车键时触发该事件

function keybutton(){

if(event.keyCode==13){ 
doStart(); 
return;
} 
}
/script>
您可能感兴趣的文章:
  • AJAX XMLHttpRequest对象详解
  • 通过XMLHttpRequest和jQuery实现ajax的几种方式
  • Ajax核心XMLHttpRequest总结
  • 解析ajax核心XMLHTTPRequest对象的创建与浏览器的兼容问题
  • 如何用ajax来创建一个XMLHttpRequest对象
  • jquery ajax学习笔记2 使用XMLHttpRequest对象的responseXML
  • AJAX中同时发送多个请求XMLHttpRequest对象处理方法
  • AJAX客户端说明,XMLHttpRequest对象
  • jQuery 利用$.ajax 时获取原生XMLHttpRequest 对象的方法

标签:揭阳 咸宁 佛山 商洛 股票 辛集 红河 荆州

巨人网络通讯声明:本文标题《使用Ajax技术通过XMLHttpRequest对象完成首页登录功能》,本文关键词  使用,Ajax,技术,通过,XMLHttpRequest,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《使用Ajax技术通过XMLHttpRequest对象完成首页登录功能》相关的同类信息!
  • 本页收集关于使用Ajax技术通过XMLHttpRequest对象完成首页登录功能的相关信息资讯供网民参考!
  • 推荐文章