The code below grabs & prints all arrays and their objects per a user's search query on SoundCloud. I do not need every object to be displayed and thus I went ahead and added slice. Though it's slicing the first few characters of the array, rather then grabbing the first few objects in each array. Where have I gone wrong?
function audioResults(){
var search = document.getElementById("search").value;
var xhr = new XMLHttpRequest();
xhr.open('GET', "https://api.soundcloud.com/tracks?client_id=1dff55bf515582dc759594dac5ba46e9&q=" + search, false);
xhr.addEventListener("load", function() {
var listResults = xhr.response;
var sliceResults = listResults.slice(0,9);
document.getElementById("results").innerHTML = sliceResults;
}, false);
xhr.send();
}
<html>
<head>
<!-- JS -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<input type="search" id="search" />
<button onclick="audioResults()">Search</button>
<p id="results"></p>
</body>
</html>