Using the following jQuery, how can I read through the values of the JSON that's returned? With it how it is, the jQuery doesn't even run as there is an error in: alert("A" + obj.sender[0]);
var session_id = $(this).find(".session_id").val();
$.ajax({
type: 'POST',
url: '../php/read.php',
dataType: "json",
data: {sesh_id: session_id},
success: function (response) {
var obj = jQuery.parseJSON(response);
alert("A" + obj.sender[0]);
},
error: function (response) {
alert("Err: " + response.status);
}
});
The value of response is:
[{
"sender":"[email protected]",
"details":"details1",
"date":"2017-01-04 16:11:04"
},
{
"sender":"[email protected]",
"details":"details2",
"date":"2017-01-04 16:11:05"
},
{
"sender":"[email protected]",
"details":"details3",
"date":"2017-01-04 16:11:06"
}]
var obj = jQuery.parseJSON(response);. Btw, you still need to add the actual error messages!