Passing multiple array to drupal_json_output() is not giving correct output in jquery ajax.
I am using a menu_callback function and returning a multiple array like
function test_callback() {
for($i = 0; $i < 10; $i++) {
$arr = array('message' => 'test'.$i, 'data' => 'data'.$i);
$arrs[] = $arr;
}
drupal_json_output($arrs);
}
Now, in the jquery, I wrote like this,
$.ajax({
url: the above url,
dataType: 'json',
success: function(data) {
$(data).each(function(key,val) {
console.log(val.message);
});
})
});
The output in the console is giving an object.
I tried to use $.each
for the val also, but the output it is returning as undefined. I tried in a lot of ways using $.get
etc. but not getting the output. Can anyone help me here??