I'm trying to loop through some data that I've passed to my JS script from PHP through AJAX.
The data is:
history: [
["1h", {
"number": "8651",
"event": "lock"
}],
["2h", {
"number": "16456",
"event": "edit"
}],
["2h", {
"number": "90",
"event": "edit"
}],
]
I've parsed the JSON using Jquery with:
var responseData = $.parseJSON(data);
history = JSON.parse(responseData.history);
But every attempt I've made at trying to access this data has thrown an error, or returned meta info about the object.
$.each(history, function (index, value) {
console.log(value);
});
returns:
function go()
function back()
function forward()
function pushState()
function replaceState()
11
auto
null
How do I access the data?
The reason for parsing twice is that
console.log(typeof responseData.history); // 'string'
Trying:
$.each(responseData.history, function (index, value) {
As per gurvinder372's answer gives the error:
TypeError: cannot use 'in' operator to search for '(b - 1)' in '[["1h",{"number"...'