
ajax
一支海棠
这个作者很懒,什么都没留下…
展开
-
axios Interceptors(拦截器) Cancellation(取消发送)
Interceptors axios.interceptors.request.use(function (config) { console.log('请求拦截器 成功'); //修改 config 中的参数 config.timeout = 2000; return config; }, function (error) { console.log('请求拦截器 失败原创 2021-06-11 19:47:01 · 564 阅读 · 0 评论 -
axios Request Config
Config Defaults全局config // 全局 axios.defaults.baseURL='http://localhost:3000' //使用默认值 btns[0].onclick =function(){ axios({ // 默认值 get 不区分大小写 method:'get', url:"/posts" }).then((res)=>{原创 2021-06-11 19:40:00 · 1460 阅读 · 0 评论 -
axios基本使用配合json-server
全部引入 json-server配置地址githubhttps://github.com/typicode/json-servernpm install -g json-server启动 json serverjson-server --watch db.json代码 //获取按钮组 var btns = document.querySelectorAll('button'); //获取所有数据 btns[0].onclick =function(){原创 2021-06-11 17:03:52 · 252 阅读 · 0 评论 -
笔记3
笔记1 ajax 跨域问题 jsonp 搜索接口ajax不允许跨域 同源策略 针对于js 对于html css不针对 协议+域名+端口号 只要有一个不相同,都算作跨域 http:127.12.12.12:8888 https:127.12.12.12:8080 为了安全 本质上不允许跨域,可以解决 1、jsonp 2、代理 3、CROSjsonp json和jsonp没有关系 J原创 2021-02-07 15:29:47 · 150 阅读 · 0 评论 -
ajax笔记2
笔记2【自己封装的ajax的用法】 ajax({ url:'',//后台的地址 type:'get|post'//传输方式 默认是get data:{}, //给后台传送的数据 {a:1,b:2} success:function(res){} //成功的函数 res是接收的数据 error:function(err){} //失败的函数 err是失败的错误信息 })【ajax的实现】 先要一个原创 2021-02-03 21:37:03 · 94 阅读 · 0 评论 -
ajax学习笔记代码
ajax学习笔记代码笔记1代码片段json testajax.jsnews.htmlnews.json 数据笔记1【Ajax的由来】ajax是javascript里面的一个技术2005年以前web1.0时代 网页都是以展示为主,内容多为静态 那个时候没有前端这个职位 美工或者叫模板工程师 后台以嵌套模板的形式开发 asp jsp php2005年以后 web2.0时代 用户不仅仅阅读静态网页,为网站做出贡献 用户体验提高了。 a原创 2021-02-01 21:28:42 · 119 阅读 · 1 评论