here i want to print the absentList array values in loop using jquery and ajax,
Here is my AJAX code
$.ajax({
type:'POST',
url :"admin_getabsentlist",
data: $('form#subjectForm').serialize(),
success: function(data) {
var res=jQuery.parseJSON(data);
console.log(res);
if(res['status']=='Success'){
$.each( res['data'], function( key, value ) {
alert(value.absentList);
});
}else{
alert('else part');
}
},
error:function(exception){
alert('Exeption:'+exception);
}
})
here if i am printing the values like console.log(res); means i am getting the results like
I am getting results
object {status: "Success", data: Object}
data:Object
absentList:Array(2)
0:'Kani'
1:'yuvi'
now i want to print the absentList values so iam using forloop like this
Forloop
if(res['status']=='Success'){
$.each( res['data'], function( key, value ) {
alert(value.absentList);
});
but here i am getting the absentList values i am getting undefined ,please tell me anyone
Expected results
in alert box i want print the values of Kani and yuvi
absentListi.e$.each(res.data.absentList, function (key, value) { alert(value); });