Cross domain jQuery get request

丶灬走出姿态 提交于 2019-12-12 02:05:17

问题


I can't figure out how to make a cross domain ajax call. My code is this:

$.ajax({
    type: "GET",
    url: "http://csgolounge.com/availableweapons",
    cache: false,
    dataType: "xml",
    success: function(data) {
        console.log(data);
    }
});

But this gives me this error, due to the same-origin policy:

XMLHttpRequest cannot load http://csgolounge.com/availableweapons?_=1413931403643. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

I've seen a few other solutions using jsonp but this is xml data, not json. I've seen others using a php proxy but I've never used php before. I just want to be able to read the xml at http://csgolounge.com/availableweapons into a variable so I can parse it on my own.

来源:https://stackoverflow.com/questions/26497674/cross-domain-jquery-get-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!