简体   繁体   中英

javascript Cross-Origin Request Blocked:

Hi I am working on simple js call between my websites,but I am getting Cross-Origin Request Blocked: error.

Here is my code:

 <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).

This problem is about the server that you want to make call.If it accepts cross origin requests this error wouldn't appear.You should check out the server configuration if it is belong to you.

Before making the request, set the header Access-Control-Allow-Origin to:

Access-Control-Allow-Origin: *

You can also install a chrome extension that will do the job for you.

This one has worked for me in the past.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM