Cross domain javascript

Discussion in 'PHP' started by goodmast3r, Aug 30, 2008.

  1. #1
    I have a domain A with javascript file. And I have also domain B which includes domain A's javascript with <script type="text/javascript" src="http://a.com/file.js"></script>

    But it currently gives error, because access denied. How can I tackle this? Google use this when displaying adsense. Why can't I do it?
     
    goodmast3r, Aug 30, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You should post this in the Javascript section. And show us the exact error you get. Usually there shouldn't be a problem. (Post also file.js)
     
    nico_swd, Aug 30, 2008 IP
  3. Hoth

    Hoth Well-Known Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    If file.js involves AJAX, browsers forbid doing an xmlhttprequest from another domain for security reasons. You have to keep it on your domain. Normal javascript will work fine across domains though.
     
    Hoth, Aug 30, 2008 IP