js编写ajax
来源:互联网 发布:java中九九乘法表 编辑:程序博客网 时间:2024/05/10 18:44
Ajax的核心是JavaScript对象XmlHttpRequest,它是一种支持异步请求的技术。XmlHttpRequest使您可以使用JavaScript向服务器提出请求并处理响应,而不阻塞用户。
使用Javascript编写一个属于自己的ajax库,可以更深刻的了解ajax的概念。
1.需要创建一个Ajax对象。
var oAjax = null;if(window.XMLHttpRequest) { oAjax = new XMLHttpRequest();} else { oAjax = new ActiveXObject('Microsoft.XMLHTTP');}
使用if语句,主要是为了浏览器的兼容性。
2.连接服务器
oAjax.open('GET',url,true);
3.发送请求
oAjax.send();
4.接收服务器的返回
oAjax.onreadystatechange=function (){if(oAjax.readyState==4){if(oAjax.status==200){fnSucc(oAjax.responseText);}else{if(fnFaild)fnFaild(oAjax.status);}}};
0 0
- js编写ajax
- 使用ajax+js编写响应菜单
- 一个js编写全选、弹出对话框、ajax-json的案例
- js-Ajax的作用及其函数的编写
- 编写Ajax
- ajax.js
- js ajax
- ajax.js
- js ajax
- js Ajax
- js ajax
- JS AJAX
- js ajax
- ajax.js
- JS:ajax
- JS-ajax
- Ajax.js
- js ajax
- eclipse安装tomcat插件
- android中layout属性
- c#调用c++写成的dll文件,返回char*,返回数组,用ref接收,byte[] (zz)
- UBOOT之main.c分析
- 无法嵌入互操作类型“MSScriptControl.ScriptControlClass”
- js编写ajax
- state 状态模式
- 主成分分析(PCA)学习有感
- 【协议分析】Wireshark 过滤表达式实例
- UBOOT之board.c分析(一)
- 支持向量机
- Why the “MAVEN2_CLASSPATH_CONTAINER will not be exported or published”
- strategy 策略模式
- jquery计算出left和top,让一个div水平垂直居中