Why doesn't jquery .load() load a text file from an external website?

前端 未结 2 740

In the example below, when I click the button, it says \"Load was performed\" but no text is shown.

I have a clientaccesspolicy.xml

相关标签:
2条回答
  • 2021-01-07 12:36

    Clientaccesspolicy has no affect on javascript. Most (maybe all?) modern browsers will prevent you from running cross-site-scripting, as it is a security risk.

    Your alternative is to proxy that site through a file on your own site, like /proxy.php?loadurl=http://theothersite.com and then call that file via the Javascript, which would be allowed since it is from your domain.

    0 讨论(0)
  • 2021-01-07 12:40

    I don't think any browser obeys clientaccesspolicy.xml or crossdomain.xml for XMLHttpRequest.

    There are other mechanisms you can look at, such as Cross-Origin Resource Sharing. This is supported by Firefox 3.5 and later.

    0 讨论(0)
提交回复
热议问题