thinkphp 设置跨域请求
2016-05-01 15:44
627 查看
场景:我的本地网页服务器无法访问本地的接口服务器接口提示一下错误:大致意思是:是一个跨域请求我的没有访问该地址的权限(接口服务器采用的是PHP编写)
解决方案:
为ajaxReturn 方法设置允许跨域访问的请求头。
参考地址:http://blog.sina.com.cn/s/blog_6751f30b0102w2x1.html,http://stackoverflow.com/questions/20433655/no-access-control-allow-origin-header-is-present-on-the-requested-resource-or
XMLHttpRequest cannot load http://localhost/mz/goods/getList. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access.
解决方案:
header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); header('Access-Control-Allow-Methods: GET, POST, PUT');
为ajaxReturn 方法设置允许跨域访问的请求头。
参考地址:http://blog.sina.com.cn/s/blog_6751f30b0102w2x1.html,http://stackoverflow.com/questions/20433655/no-access-control-allow-origin-header-is-present-on-the-requested-resource-or
相关文章推荐
- PHP关于Ajax返回多个json数据的处理
- 【1】引用计数基本知识
- JetBrains PhpStorm 所有版本通用注册码
- PHP基础之进制的转换
- PHP (sendmail / PHPMailer / ezcMailComposer)发送邮件
- 配置FTP服务器——passive mode
- ubuntu 16.04 php 开发环境搭建
- PHP数据库拓展之PDO使用总结
- PHP中define()和dirname(__FILE__)
- php 操作数组array_merge使用时数组包含数字键名的问题解决方法
- thinkphp3.2.3连接sqlserver 2008 R2 数据库
- Thinkphp if标签不起作用 变量嵌套层次太多的原因
- IOS推送服务端PHP简要记述
- 3. 安装 phpmyadmin
- laravel的安装
- Laravel小技巧
- php面向对象一
- php面向对象二之封装,protected ,public,private权限管理
- php面向对象三,继承父类extends
- php面向对象四。多态静态方法和属性