AJAX Asynchronous JAvaScript and
异步刷新,不需要提交自己数据刷新页面。
1.创建XHR对象(javascript对象),在用户没有感觉的情况下悄悄和服务器进行数据交互就像背后运行的一根小线程一样
2.设置响应函数,当服务器响应回来时调用处理函数
xmlhttp.onreadystatechange=checkResult就可以指定用checkResult函数进行处理
3.设置并发出请求
通过open函数设置背后的这个小线程,
xmlhttp.open("GET",url,true);//url就是将要访问的页面
xmlhttp.send(null);//null表示没有参数,因为参数已经通过"GET"方式放在url里了。只有在用"POST",并且需要发送参数的时候才会使用到send
类似这样xmlhttp.send("user="+username+"&password="+password)
4.处理响应信息
在checkResult函数中处理响应
![](https://img.haomeiwen.com/i1065258/52be405ab5470d7f.png)
AJAX.png
本文标题:AJAX Asynchronous JAvaScript and
本文链接:https://www.haomeiwen.com/subject/owrjkftx.html
网友评论