I want to fetch the values in the List array from the json object.
Here is my JS / Ajax code:
$.ajax({
type: 'GET',
url: "http://127.0.0.1:8000/api/sort_api/" + a,
contentType: 'application/json',
dataType: 'json', //specify jsonp
success: function(data) {
var htmlData= '';
for(var i=0; i<data.length; i++){
htmlData+= '<li>'+data[i]+' </li>';
}
$('#list').html(htmlData);
// alert(list);
console.log(data);
}.bind(this),
error: function(e) {
console.log('error', e);
}
});
Here is the console log(data) result:
{status: "200", status_message: "List Sorted", List: Array(5)}
List:(5) ["Abc", "Take 78A", "Take Airport", "Take flight", "Take flight"]
status:"200"
status_message:"List Sorted"
When i write console.log(data['status'])
It shows the value 200 in console
But when i write console.log(data['list']);
it shows undefined
Can somebody tell me what i am missing? I want to retrieve the array(List) in that object
console.log(data['List'])? Its case sensitivedata = JSON.parse(JSON.stringify(data[0]));. And you have the same issue in this LINK