简单的Ajax封装
2014-04-07 16:42
225 查看
简单的ajax封装: function ajax(url,onsuccess,onfail) { var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); xmlhttp.open("POST", url, true); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { onsuccess(xmlhttp.responseText); } else { onfail(xmlhttp.status); } } } xmlhttp.send(); //这时才开始发送请求 }
相关文章推荐
- 用javascript简单封装AJAX
- Ajax代码简单封装。
- 原生AJAX封装的简单实现
- 简单封装ajax
- 简单封装$.ajax() 方法
- 简单封装了下基本的AJAX实现
- 用原生JS对AJAX做简单封装的实例代码
- Extjs读取更改或者发送ajax返回请求的结果简单封装
- 简单的AJAX封装的三级联动
- javascript实现简单的ajax封装示例
- Ajax Zero to Hero (2)入门代码的简单封装
- ajax的简单封装
- 自己写的封装好的简单的AJAX--javascript (改良版)
- ajax简单封装
- ajax请求简单封装
- 自己写的封装好的简单的AJAX--javascript (改良版)
- AJAX简单封装
- ajax代码及简单封装
- jquery封装ajax(建议使用比较简单)
- 使用Promise封装简单Ajax方法