<script type="text/javascript">
function check(){
var account=document.loginForm.account.value
var pwd=document.loginForm.password.value
var xmlHttp;
if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}else if (window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open("post","ajax.jsp?account="+account+"&password="+pwd,true);
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
xm.innerHTML=xmlHttp.responseText
}else{
xm.innerHTML="正在登录,请稍等..."
}
}
xmlHttp.send();
}
</script>
<form name="loginForm">
姓名<input type="text" name="account" ><BR>
密码<input type="password" name="password"><BR>
<input type="button" value="OK" onclick="check()">
</form>
<hr>
<span id="xm"></span>
</body>
ajax.jsp内容
<%
String account= request.getParameter("account");
String pwd= request.getParameter("password");
if(account.equals(pwd)){
out.println("登录成功");
}
else{
out.println("登录失败");
}
%>
XMLHTTPRequest对象什么是
mlHttp是一套可以在Javascript、VbScript、Jscript等脚本语言中通过http协议传送或从接收 XML及其他数据的一套API。XmlHttp最大的用处是可以更新网页的部分内容而不需要刷新整个页面
属性:
Property Name Type/Description
onreadystatechange Callback function; set this to a function that will be called whenever readyState changes.
readyState Number; 0 means uninitialized, open() has not yet been called; 1 means loading, send() has not been called; 2 means loaded, send() has been called and headers/status are available; 3 interactive, responseText holds partial data; 4 means completed.
responseText string; the plain text of the response.
responseXML DOM Document object; an XML return value.
status Response status code, such as 200 (Okay) or 404 (Not Found).
statusText string; the text associated with the HTTP response status.
分享到:
相关推荐
"扩展的aja项目"可能是指一个基于Ajax(异步JavaScript和XML)的项目,它强调了动态网页更新和数据交换的重要性。Ajax允许我们在不刷新整个页面的情况下与服务器进行通信,提升用户体验。 在Web开发中,后台开发...
3. **设计部门**:设计人员通常需要高性能的工作站,推荐的联想ThinkStation P300 SFF-30AJA05000工作站,配备了i7-4790处理器,4GB内存,1TB硬盘,无光驱,运行DOS系统。价格为5099元。此外,苹果iMac ME086CH/A,...
1. **Ionic React**: 了解 Ionic 的组件体系,如 `IonPage`, `IonHeader`, `IonContent`, `IonFooter` 等,以及如何通过 React Hooks(如 `useState` 和 `useEffect`)来管理状态和生命周期。 2. **TypeScript**: ...
笔记 : JANGAN UBAH NAMA BOT BIAR BOTNYA GAK RUSAK! 对于TERMUX用户 > pkg update && pkg upgrade > pkg install git -y > pkg install nodejs -y > pkg install ffmpeg -y > pkg install imagemagick -y > git...
前言 单页面应用大多采用前后端分离开发思路,我们知道,前端和后端交互有多中方式(服务器端渲染、Ajax、websocket等),今天我们主要讲解Ajax部分。 最近团队讨论了一下,Ajax 本身...vue更新至2.0之后,官方推荐的Aja
笔记 此投资组合仍未响应。 使用GSAP动画 app.js文件仍然非常混乱,因为我没有在GSAP动画中使用时间轴。 *这里是GSAP CDN。 万一您想使用它。 < script src =" ...