随笔分类 - AJAX
摘要:function axios(method, url) { return new Promise((reslove, reject) => { let xhr = new XMLHttpRequest() xhr.onreadystatechange = function () { if (xhr.
阅读全文
摘要:1.jsonp的方法 //ajax封装的jsonp,jsonp本质上是通过script标签的src属性解决的跨域问题,只能解决get类型的请求 $.ajax({ url: 'http://127.0.0.1:3000/fruits', dataType: 'jsonp' }).done(res =>
阅读全文
摘要://axios封装的ajax //get方法返回值是一个promise方法 // document.querySelector('.get').onclick = function () { // axios.get('/fruits').then(res => { // console.log(r
阅读全文
摘要://ajax的回调函数的封装,建议不使用回调函数处理异步问题 let btn = document.querySelector('button') btn.addEventListener('click', () => { ajax('get', '/data', function (res) {
阅读全文