How can I make a API request with the "search/setlist" endpoint from my HTML code?

How can I make a API request with the "search/setlist" endpoint from my HTML code?

Posted 8 Feb 2017, 13:52:33

Hello!
There is my problem. I try with my html code to make a request toward this website to get the information about a artist's setlists with this REST Endpoint: http://api.setlist.fm/docs/rest.0.1.search.setlists.html . But its always send me the message that the “Access-Control-Allow-Origin” header is missing. For help you to get a idea of what I'm trying to do, there is my code:

<button onclick=“lancer('http://api.setlist.fm/rest/0.1/search/setlists.xml?artistName=metallica/')”>setlist</button>
<script>
var lancer= function(url) {

xhr= new XMLHttpRequest(); xhr.open('GET', url); xhr.onreadystatechange = function() { if (xhr.readyState 4 && (xhr.status 200 || xhr.status == 0)) { alert(xhr.responseXML); }
}; xhr.send(); }
</script>
The alert show me that the xhr variable is “null”, proof that he don't get the XML file that I'm looking for and I got the error that I have been talking earlier. If someone could help me its very important cause I'll need this for one of my project.

Last edited 8 Feb 2017, 13:58:19

Post Reply

You're not allowed to do this, please sign in first.