如何在javascript中将数组从php返回到ajax响应

fed*_*ick 4 javascript php arrays ajax

如何将php中的数组返回给ajax调用,

ajax电话:

$.post('get.php',function(data){
alert(data)

});
Run Code Online (Sandbox Code Playgroud)

get.php

$arr_variable = array('033','23454')
echo  $arr_variable;
Run Code Online (Sandbox Code Playgroud)

在警报(数据)中,它显示为数组(即仅文本),当我显示数据[0]时,数组的第一个字母即A正在显示.

有什么建议 ?我做错了

Gau*_*164 11

用于编码数组

$data['result'] = $arr_variable;
echo json_encode($data);
exit;
Run Code Online (Sandbox Code Playgroud)

并且在成功函数中试着parseJSON像它一样

$.post('get.php',function(data){
    var res = $.parseJSON(data);
    alert(res.result)
});
Run Code Online (Sandbox Code Playgroud)