如何绕过访问控制 - 允许 - 原产地? [英] how to bypass Access-Control-Allow-Origin?
问题描述
我正在做的事情,他们设置prevent这些Ajax调用(但我需要它从我的服务器获取数据,显示从我的服务器的数据库中检索数据)的平台一个Ajax调用自己的服务器。
我的AJAX脚本运行,它可以通过将数据发送到我的服务器的PHP脚本,使它能够处理。
然而,它不能处理的数据后面,因为它是阻止访问控制 - 允许 - 起源
I'm doing a ajax call to my own server on a platform which they set prevent these ajax calls (but I need it to fetch the data from my server to display retrieved data from my server's database).
My ajax script is working , it can send the data over to my server's php script to allow it to process.
However it cannot get the processed data back as it is blocked by "Access-Control-Allow-Origin"
我要该平台的源/核心进行访问。所以我不能删除它不允许我这样做的脚本。 (P / SI采用谷歌Chrome浏览器的控制台,并发现了这个错误)
I have no access to that platform's source/core. so I can't remove the script that it disallowing me to do so. (P/S I used Google Chrome's Console and found out this error)
如下图所示阿贾克斯code:
The Ajax code as shown below:
$.ajax({
type: "GET",
url: "http://example.com/retrieve.php",
data: "id=" + id + "&url=" + url,
dataType: 'json',
cache: false,
success: function(data)
{
var friend = data[1];
var blog = data[2];
$('#user').html("<b>Friends: </b>"+friend+"<b><br> Blogs: </b>"+blog);
}
});
或者是有一个 JSON
相当于code以上的AJAX脚本?我觉得 JSON
是允许的。
or is there a JSON
equivalent code to the ajax script above ? I think JSON
is allowed.
我希望有人可以帮助我。
I hope someone could help me out.
推荐答案
把它放在retrieve.php顶部
put it on top of retrieve.php
header('Access-Control-Allow-Origin: *');
这篇关于如何绕过访问控制 - 允许 - 原产地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!