rubensayshi / gw2spidy

GW2Spidy - Guild Wars 2 Tradingpost Graphs
http://www.gw2spidy.com
231 stars 86 forks source link

API should support CORS requests #144

Closed jsumners closed 10 years ago

jsumners commented 10 years ago

It really should -- http://www.w3.org/TR/cors/

rubensayshi commented 10 years ago

hmm it has "Access-Control-Allow-Origin: *" header

jsumners commented 10 years ago

http://jsfiddle.net/9LEjy/ which is:

$.ajax({
    url: "http://www.gw2spidy.com/api/v0.9/json/item-search/the%20jugg",
    dataType: "json",
    success: function(data, status, jqXHR) {
        $("output").html( JSON.stringify(data), null, "\t");
    }
});

Results in:

"XMLHttpRequest cannot load http://www.gw2spidy.com/api/v0.9/json/item-search/the%20jugg. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access."

rubensayshi commented 10 years ago

http://jsfiddle.net/y3qqQ/

the problem is that the framework redirects /item-search/thejugg to /item-search/thejugg/ and in the redirect process it seems to lose the Access-Control-Allow-Origin header :(

let me see if I can easily fix that

rubensayshi commented 10 years ago

your example now works too, asuming you change $("output") to $("#output") ;)

jsumners commented 10 years ago

Yay for bugs all around!

Glad I wasn't reporting a non-issue and that you were able to solve the problem.