js中回调函数
来源:互联网 发布:淘宝买身份证 编辑:程序博客网 时间:2024/04/30 12:33
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="../js/jquery-1.8.1.min.js"></script></head><body> <input type="button" id="ok" value="click me"/> <script type="text/javascript"> //封装Ajax var ajaxObj = { xmlhttpresquest: '', getXMLHttpRequest: function () { var xmlHttp; try{ xmlHttp = new XMLHttpRequest();//FireFox,Opera 8.0,Safari } catch (e) { try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");//IE } catch (e) { try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } return xmlHttp; }, post: function (ajaxJson) { ajaxObj.xmlhttpresquest = ajaxObj.getXMLHttpRequest(); ajaxObj.xmlhttpresquest.onreadystatechange = function () { if (ajaxObj.xmlhttpresquest.readyState == 4) {//响应完毕 if (ajaxObj.xmlhttpresquest.status == 200) {//成功响应 //回调函数 ajaxJson.callback(ajaxObj.xmlhttpresquest.responseText); } } } ajaxObj.xmlhttpresquest.open(ajaxJson.method, ajaxJson.url, true); ajaxObj.xmlhttpresquest.send(ajaxJson.data); } }; window.onload = function () { document.getElementById('ok').onclick = function () { ajaxObj.post({ method: 'post', url: 'Handler1.ashx', data: 'name=wj', callback: function (data) { alert('回调函数:'+data); } }); } } </script></body></html>
0 0
- js中回调函数
- js中自定义回调函数
- js中回调函数的运用
- JS中回调函数的写法
- js 中递归 与 回调函数
- js 中递归 与 回调函数
- js回调函数
- js回调函数
- JS回调函数
- js回调函数
- js回调函数
- js回调函数
- js回调函数
- js-回调函数
- JS回调函数
- js回调函数
- js 回调函数
- js回调函数
- android之popupwindow点击空白消失
- 单一入口机制
- jQuery中自定义事件
- userdebug的版本 adb root
- 链表的回文结构
- js中回调函数
- sorted的学习记录
- Node.js包的管理
- js中的this
- 如何用虚拟机装SQL Server
- js中的匿名函数
- Atitit.编程语言and 自然语言的比较and 编程语言未来的发展
- iOS 类别 ---不能添加属性
- 在Android Studio中导入library项目开源库