简体   繁体   中英

XMLHttpRequest cannot load. Origin is not allowed by Access-Control-Allow-Origin

Im using this code to call json file, i checked it with jslint "Results : Valid JSON", it is correct, I used it few months, but today suddenly stopped working, the console shows this.

XMLHttpRequest cannot load http://www.weburl.com/web/calc/filethree.js . Origin http://www.weburl.com/ is not allowed by Access-Control-Allow-Origin.

$.getJSON("http://www.weburl.com/web/calc/filethree.js",function(datathree){
        $.each(datathree, function(i,value){
        // do something
        });
        }
);

Im newbie in jquery, I searched some info, tried callback= , but nothing .. :/

With callback I get 404 error

http://www.weburl.com/web/calc/filethree.js&callback=jQuery180014668452506884933_1349693824272?_=1349693824434

I dont know what happened It worked prefectly yesterday :/

I changed the url, and now Im now using relative URL , @devnull69 advise was helpfull, and now it is works. Solution: Try the relative URL web/calc/filethree.js instead of the absolute one – by @devnull69

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