Skip to content Skip to sidebar Skip to footer

Cross Domain Ajax Call, Authorize All Requests For File's Content?

I want to provide other sites with a banner from my site but I want to keep the banner on my server and have them include it with javascript, like Facebook plugins/google ads do. T

Solution 1:

It appears you are running into the normal JS cross-site scripting restrictions. By default cross-site scripting capabilities apply some restrictions on what and who can call the endpoint. You didn't provide any sample of what you are trying to do code wise but you can check out this link as an example: http://jquery-howto.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html

EDIT:

It would help to see the JavaScript call itself but if you plugin the error to Google or Bing the first result for me was another SO post: XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin

Solution 2:

With javascript/jquery you can draw an iframe instead of a div, and set its src attribute to the url of your banner.

$('<iframe />', {
    name: 'myFrame',
    id:   'myFrame',
    src:  'http://www.mywebsite.com/'
}).appendTo('body');

Post a Comment for "Cross Domain Ajax Call, Authorize All Requests For File's Content?"