I’m new with jQuery and JavaScript. I’m trying to make a HTTP GET request with the get() function. Below I’ve reported a part of my code. I don’t understand why the http request doesn’t work. Thanks for any advice!
var jqxhr = $.get("http://lyricwiki.org/api.php?func=getSong&artist=Tool&song=Schism&fmt=xml",
function() {
alert("success");
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });
I’m assuming you’re serving this on a different domain than lyricwiki.org, in which case you’re violating the same origin policy.
Edit: the good news is that they seem to have a funky alternative to JSONP that will let you request it cross-domain as a raw JavaScript file: http://lyrics.wikia.com/LyricWiki:REST#Response_Formats. Here’s an example: http://lyrics.wikia.com/api.php?artist=Slipknot&song=Before_I_Forget&fmt=js