【发布时间】:2014-03-01 12:23:09
【问题描述】:
如果我这样做:
jQuery.ajax({
url: 'http://server.com/script.php',
type: 'POST',
crossDomain: true,
data: complete_data,
complete: function(response, textStatus) {
if (textStatus === 'success') {
jQuery('#content > form').html(response.responseText);
}
}
});
然后 server.com 上的 script.php 看起来像这样:
我工作的防火墙不允许我在其中发布带有脚本标签的内容,但想象一个 php 脚本将 javascript 脚本标签回显到 URL https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places
然后我得到这个错误
XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://my-local-machine.dev' is therefore not allowed access.
我应该在哪里设置 Access-Control-Allow-Origin 标头以使其正常工作?
【问题讨论】:
标签: php jquery ajax cross-domain