12345678910111213141516 |
- function ajaxFun(url,foo) {
- // 第一步 创建XMLHttpRequest 对象;
- var xmlh = new XMLHttpRequest();
- // 第二步 发送请求
- xmlh.open("GET", url, true);
- xmlh.send();
- // 第三步 处理请求结果
- xmlh.onreadystatechange = function () {
- if (xmlh.readyState == 4 && xmlh.status == 200) {
- var resObj = JSON.parse(xmlh.responseText)
- // console.log(resObj)
- // return resObj;
- foo(resObj)
- }
- }
- }
|