XMLHttpRequest Origin is not allowed by Access-Control-Allow-Origin

后端 未结 2 503
醉梦人生
醉梦人生 2020-12-20 09:57

I\'m trying to fetch some simple text over HTTP from JavaScript:

$(function() {
    $.get(\"http://mydomain.com/path\", function(result) {
        console.lo         


        
相关标签:
2条回答
  • 2020-12-20 10:05

    You've simply gotta use either PHP/ASP your serverside language to retrieve the cross-domain request or use a service such as a cross domain ajax service created by Yahoo!.

    It uses JSONP which is allowed to do very strict cross-domain requests, but asking from Yahoo! they will retrieve any page on the internet.

    http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/

    0 讨论(0)
  • 2020-12-20 10:18

    You can't request that page because of Same Origin Policy unless that page has explicitly allowed you with CORS.

    Either proxy it server side, with a service such as YQL, get it as JSONP or get the other service to enable CORS for your domain.

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