I get a json response from a ajax request, the response is the follow:
{
1: {
id: 1,
title: "departure1 - arrival1",
start: "2018-01-01 12:01:00"
},
2: {
id: 2,
title: "departure2 - arrival2",
start: "2018-02-01 12:02:00"
}
}
I try to index that int the follow mode, but obviously doesn't work becous is only one object, but i hope thate with this i can explain better what i want do:
var xhr = new XMLHttpRequest();
xhr.onload = function () {
if(xhr.status === 200) {
var responseObject = JSON.parse(xhr.responseText);
for(var i=0; i<responseObject.length; i++) {
console.log(responseObject[0]);
}
}
};
var url = 'http://localhost:8081/get_transfer_booked';
xhr.open('GET', url, true);
xhr.send(null);