Ajax测试

来源:互联网 发布:国产手办淘宝哪家好 编辑:程序博客网 时间:2024/06/03 16:48

 1 什么是AJAX=HMTL+CSS+JS+DOM+XHR

   1)传统Web应用是以请求->等待响应->请求->等待响应->....的过程,叫同步请求/操作
   2)现代Web应用是以请求->请求->请求->响应->响应->响应->...,叫异步请求/操作

   3)现代Web应用以Ajax为主流,Ajax=C/S表面现象+B/S本质

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>ajax初体验</title></head><body><div align="center"><input type="button" id="btu" value="ajax体验" /><hr /></div><script type="text/javascript">var btuElement = document.getElementById("btu");btuElement.onclick = function() {//alert("a");var xhr = createXHR();window.alert(xhr != null);}function createXHR() {//是ieif(window.ActiveXObject) {xhr = new ActiveXObject("microsoft.xmlhttp");} //非ieelse {xhr = new XMLHttpRequest();}return xhr;}</script></body></html>


原创粉丝点击