Q:

Handle PHP Array in Ajax Response

I send an AJAX request to a PHP file with this code:
$.post({
    url: "manage.php",
    dataType: "JSON"
}, {
    firtname: John, 
    lastname: edwin
}, function(data){
    $("#persons").html(data[0])
}); 

My PHP file returns data in an array such as this:
$a = 0;
while ($a < 5) 
{
    $data[$a] = "person".$a; 
    $a2++;
}
echo json_encode($data);

I want to return data something like $data[0] = "person 1";. How can I handle this in AJAX? As you can see above currently I am trying data[0] but no success. How can I do this? Thanks

A:

i solved the problem. Sorry guys, there was a syntax error in my variable thats why i was not getting data in my ajax response. so the following code is correct & working
$.post({
url: "manage.php",
dataType: "JSON"
}, {
firtname: John, 
lastname: edwin
}, function(data){
$("#persons").html(data[0])
}); 

in my php file my Array variable was wrong thats why i was not getting data. sorry and thanks :)

