访问控制 - 允许 - 原产地不是从codeigniter表示响应头了 [英] Access-Control-Allow-Origin is not showing up in response headers from codeigniter

查看:121
本文介绍了访问控制 - 允许 - 原产地不是从codeigniter表示响应头了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的codeigniter文件说:

My Codeigniter file says

$CI->output->set_header("Access-Control-Allow-Origin: *");
$CI->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
$CI->output->set_status_header(200);
$CI->output->set_content_type('application/json');
echo json_encode(array("city" => "dhaka"));

但HTTP响应,我得到的是:

but the http response that i get are:

Request URL:http://localhost/index.php/location/city
Request Method:POST
Status Code:200 OK

Connection:Keep-Alive
Content-Length:16
Content-Type:text/html
Date:Sun, 22 Jul 2012 10:27:32 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6
X-Powered-By:PHP/5.3.6

访问控制 - 允许 - 原产地是即使经过包括访问控制 - 暴露,标题中缺少响应:访问控制 - 允许 - 原产地。我的这个标题信息来源是从 Mozilla开发者网站

The header Access-Control-Allow-Origin is missing in the response even after including Access-Control-Expose-Headers: Access-Control-Allow-Origin. My source of information about this header is from Mozilla Developer Website

推荐答案

事实证明,它的工作对我来说,只有当我通过PHP语法设置的标头头() $ CI->输出 - > set_header()。这是可悲的。

It turns out, it worked for me only when i set the headers via the PHP syntax header() instead of the codeigniter syntax $CI->output->set_header(). That's sad.

感谢<一href="http://stackoverflow.com/questions/11599573/access-control-allow-origin-is-not-showing-up-in-response-headers-from-$c$cignit/13537626#comment15353383_11599573">first在按@Yan 评论的问题这个话题

Thanks to the first comment by @Yan at the Question of this topic

这篇关于访问控制 - 允许 - 原产地不是从codeigniter表示响应头了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆