码迷,mamicode.com
首页 > 其他好文 > 详细

前端请求接口出现的跨域问题

时间:2019-03-27 21:31:44      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:cache   应用   code   options   pre   charset   request   ons   let   

1.针对跨域问题可以使用jsonp的方式解决

2.可以使用header头来定义

header(‘Access-Control-Allow-origin:*‘);
header(‘Access-Control-Allow-Credentials:true‘);
header(‘Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS‘);
header(‘Access-Control-Allow-Headers:Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With‘);
header(‘Content-Type: text/html; charset=utf-8‘);

加上以后就可以了

但是这个缺陷是IE10以下的不支持!一般手机应用都可以用!

前端请求接口出现的跨域问题

标签:cache   应用   code   options   pre   charset   request   ons   let   

原文地址:https://www.cnblogs.com/findher/p/10610601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!