function httpGetAsync(theUrl, callback) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
httpGetAsync("/api/v1/items", (res)=>{
// page content is in variable "res"
});
document.addEventListener("DOMContentLoaded", function() {
const xmlHttp = new XMLHttpRequest(),
div = document.getElementById('music_all_ajax');
xmlHttp.open("GET", '{{ route('music ') }}', false); // false for synchronous request
xmlHttp.send(null);
div.insertAdjacentHTML('afterbegin', xmlHttp.responseText);
});