【发布时间】:2013-04-11 02:15:20
【问题描述】:
我在使用 Google Chrome (v26.0.1410.64m) 时遇到了这个问题。 当我使用 jquery 调用 Twitter 搜索时,出现以下错误:
GET https://search.twitter.com/search.json?q=youtube&rpp=5&result_type=recent&callback=jQuery19101530768966767937_1365645647773&_=1365645647774 403 (Forbidden)
这是我使用的代码:
$.ajax({
type: "GET",
url: "https://search.twitter.com/search.json?q=youtube&rpp=5&result_type=recent",
contentType: "application/json",
dataType: "jsonp",
success: function(data) {
console.log(data);
}
});
在 Firefox、Internet Explorer、Safari 和 Opera 上可以正常工作。但是在 Chrome 中我有这个禁止的错误。我尝试在我的 .htaccess 中添加以下跨域代码:
Header set Access-Control-Allow-Origin: *
Header set Access-Control-Allow-Credentials: true
什么都没有改变。我哪里错了? 如果这有帮助,我正在使用 Windows/Apache 上的虚拟域(en.domain.com.local、fr.domain.com.local 等)在开发环境中工作。
感谢您的帮助。对不起我的英语。
【问题讨论】:
-
在 Chrome 中工作,至少在这个 fiddle 中。
-
确实.. 所以这是我的 Apache 配置?
-
假设您是从 HTML 代码调用它,您的 Apache 和 .htaccess 配置应该与此无关。
-
好吧,这很奇怪。我哪里错了?您需要有关某事的更多信息吗?感谢您的帮助。
标签: javascript ajax json