php - jQuery $.get() Array Returns [object Object] -
test.php includes this:
echo json_encode( array( array("name"=>"john","time"=>"2pm"), array("name"=>"2","time"=>"1242pm"), array("name"=>"j231ohn","time"=>"2p213m"), ));
jquery:
$.get("test.php", function(data) { $.each(data, function(n, val) { alert(n + ': ' + val) }); }, "json");
this result:
0: [object object] 1: [object object] 2: [object object]
what doing wrong?
try:
alert(n + ': name = ' + val.name + ' time = ' + val.time);
Comments
Post a Comment