<?
 function phpfunction(){

 //insert data to database //some codes work inside this.

$return_arr[] = array($arrResult,         // include only one value
                      $response_array['status'] );//success or not success value

return $return_arr;
}
?>


此$ return_arr []值返回到javascript ajax文件>>

                    $.ajax({
                            url: 'PHPMethodCalls_AL.php',
                            type: 'post',
                            data: {... post many values to php function..   },
                            success: function(data) {
                            alert(data);


//以这种格式成功发送数据>> [[[[“ Testing123”],“ success”]]

                            var results = JSON.parse(data);
                            alert(results);


//此警报得到了>> Testing123,成功

                        },


//这是后值功能

$newCIarrayList = array();
$newCIarrayList = phpfunction(..data include );
echo json_encode($newCIarrayList);


我应该怎么做才能分别获取每个值作为“ Testing123”和“成功”值?我尝试了split(“,”)函数,但是没有用。

最佳答案

您可以在响应下面的ajax之前在php函数中进行分离。

<?
 function phpfunction(){

    //insert data to database //some codes work inside this.

    $return_arr = array("data"   =>$arrResult,         // include only one value
                        "status" =>$response_array['status'] );//success or not success value
    return $return_arr;
}
?>
var结果= JSON.parse(数据); alert(results.data || results.status);

10-06 15:23