How can I extract the name and status from a JSON object?
I've attempted various methods like [0] - [1], as well as trying without, but to no avail.
[
{
"status": "OK"
},
{
"id": "1",
"name": "name test test"
},
{
"id": "1",
"name": "name test"
},
{
"id": "1",
"name": "test name"
}
]
AJAX
$.ajax({
url:'url',
method: 'get',
dataType: 'text',
success: function(response){
if (response.status === "200") {
$.each(response, function(i, data) {
alert(data.name);
});
} else {
alert('error status');
}
}
});