嗨,我正在网站之间进行简单的js调用,但是我收到了跨域请求被阻止:error。
这是我的代码:
<script>
$.getScript( "http://myts1.com/rotator.js?1418419096" )
.done(function( script, textStatus ) {
new PFRotator({'width': '300', 'height': '250', 'vertical': '12, '}, 'PF300x250', '395953', '', '', 'Yes');
})
.fail(function( jqxhr, settings, exception ) {
$( "body" ).text( "Triggered ajaxError handler." );
});
</script>
ERROR :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myts1.com/GETBANNERS.php?width=300&height=250&width=300&height=250&vertical=12%2C%20&mode=banner&mobile=false. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
答案 0 :(得分:0)
此问题与您要拨打的服务器有关。如果它接受跨源请求,则不会出现此错误。您应该检查服务器配置是否属于您。
答案 1 :(得分:0)
在发出请求之前,将标头Access-Control-Allow-Origin设置为:
Access-Control-Allow-Origin: *
您还可以安装chrome扩展程序来为您完成这项工作。
This one过去为我工作。