I\'m using an XMLHttpRequest to access SoundClouds Top Trending Tracks (https://api-v2.soundcloud.com/charts?kind=trending&genre=soundcloud:genres:all-m
You are using XMLHttpRequest wrong. Do asynchronous request instead of synchronous. Here is a fixed version:
function initialSearch() {
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", function() {
initialArray = JSON.parse(xhr.response);
}, false);
xhr.open('GET', "https://api-v2.soundcloud.com/charts?kind=trending&genre=soundcloud:genres:all-music&client_id=1dff55bf515582dc759594dac5ba46e9&q=");
xhr.send();
}
But even then, you will get No 'Access-Control-Allow-Origin' header is present on the requested resource
error. Which is CORS browser policy error. You can only make requests to the same origin resources.
So if you can modify your server code, do that request from your server and change your client AJAX request to ask data from your server.