Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery返回后多维数组_Javascript_Jquery_Ajax_Json - Fatal编程技术网

Javascript jQuery返回后多维数组

Javascript jQuery返回后多维数组,javascript,jquery,ajax,json,Javascript,Jquery,Ajax,Json,此多维数组将返回到jQuery foreach($results as $result) { $note_id = $result->ID; $return_array[$note_id]['status_type'] = $result->status_type; $return_array[$note_id]['note'] = $result->notes;

此多维数组将返回到jQuery

    foreach($results as $result) {
                $note_id = $result->ID;
                $return_array[$note_id]['status_type'] = $result->status_type;
                $return_array[$note_id]['note'] = $result->notes;
                $return_array[$note_id]['username'] = $result->username;
                $date_time = $result->updated;
                    $timestamp = strtotime($date_time);

                $day_submitted =  date("F jS Y", $timestamp);
                $time_submitted = date("H:i", $timestamp);

                $return_array[$note_id]['date_time'] = "$day_submitted<br>$time_submitted";

            }

echo json_encode($return_array);

如何解决?

您没有将字符串
解析为
JSON

response = JSON.parse(response);

将此添加为
post
回调中的第一条语句。

jQuery不会智能地猜测数据格式:o@Huey不需要,您需要提供,但是从,如果未指定,默认数据类型是*智能猜测(xml、json、脚本、文本、html)*。抱歉,我只是好奇。@Huey这是发布数据的
数据类型,而不是
响应的
数据
response = JSON.parse(response);