I have the following JSON object:
[
{
"comments": [
{
"created_at": "2011-02-09T14:42:42-08:0
You have to mention the dataType in the ajax request as 'JSON'. Make user you did that like below.
$.ajax({
url: $('#frmAddCourse').attr('action'),
type: 'POST',
data: $('#frmAddCourse').serialize(),
dataType: 'JSON',
success: function (data){
Materialize.toast(data['state'],2000);
},
error:function(){
Materialize.toast(errorMessage,2000);
}
});