I need to iterate through a JSON object in JavaScript or jQuery that is returned from a PHP file with the a json_encode function call:
echo json_encode ($varDump);
The beginning of the JSON objects looks like the following:
["date","Rescription",{"date":"1715-05-03","description":"Edmund Halley observes total eclipse phenomenon \"Baily's Beads\""},{"date":"1765-05-03","description":"1st US Medical school opened"},{"date":"1797-05-03","description":"Jamaica discovered by Columbus"},{"date":"1802-05-03","description":"Washington, D.C., was incorporated as a city."},{"date":"1830-05-03","description":"1st regular steam train passenger service starts"},
I need to pull out the date and the description.
I tried the following but I am getting errors:
count = data.length - 1;
for(i=0; i < count; i++){
$('#currentText').html(data.date[i]);
$('#currentText').html(data.description[i]);
}
The value in count on my test case seems way high, as if it’s counting characters and FF says data.date is not an object.
How would I go about doing this?