随笔分类 - ajax
摘要:ajax请求,首先需要服务器(首先你需要node) 其次,进入当前目录(默认服务器端口8080) 点击进入:localhost:8080/apply-ajax.html apply-ajax.html (推荐封装ajax,以及ajax转码过来或者转码回去后台) test.json(前台可以先做jso
阅读全文
摘要:// 方案2: 回调函数 // function getFile( callback ){ // // 1: 创建ajax对象 XMLHttpRequest // var xhr = new XMLHttpRequest(); // // 2: 打开通道 // xhr.open( 'get', 'test.txt', true ); // // ...
阅读全文
摘要:var api = 'http://192.168.68.208:666/ajax/api.ashx'; // api += 'action=/api/blackhistory/list&keywords=&isPage=1&pageNo=1&pageCount=5' // var api = 'test.txt'; // 获取异步数据 function ajax( callback ...
阅读全文
摘要:var apiroot = 'http://192.168.68.208:666/ajax/api.ashx'; // function ajax( method, param, callback ){ function ajax( params ){ var req = new XMLHttpRequest(); // 默认参数 var opt = { ...
阅读全文
摘要:// 1: 创建ajax对象 XMLHttpRequest var xhr = new XMLHttpRequest(); // 2: 打开通道 // 请求方式 // 请求地址 // 是否异步 默认true, false xhr.open( 'get', 'test.txt', true ); // 3: 发送请求 xhr.send(); // 4:监听通道 xhr.onready...
阅读全文