试图返回一个json数组,但我收到JSON Parse错误

时间:2016-03-18 00:40:52

标签: php jquery json

对于任何可以提供帮助的人,我正在尝试返回一个数组并且正在获取 当我通过http://jsonlint.com运行它时,JSON解析错误 回来很好。有没有人得到一些建议,因为我一直在这 很长一段时间,无处可去。感谢任何可以提供帮助的人。

     $.ajax({  
      url: 'images/retrieve_images.php',    
      data: 'page_id='+ encodeURIComponent(page_id),
      dataType: 'json',
      success: function(data) {

      var results = $.parseJSON(data);

        $.each(results, function(i, result) {

        $("<img width='50px' height='auto' src='../article_images/"+result.image_name+"'/>").appendTo("#image_list");
        $("<p>"+result.original_image_name+"</p>").appendTo('#image_list');

        if (result.image_layout == "normal") {
        $("<p><input type='checkbox' name='normal' id='element_id' class='background_input element_id' value='normal' checked> Normal</p>").appendTo('#image_list');
        $("<p><input type='checkbox' name='extended' id='element_id' class='background_input element_id' value='extended'> Extended</p>").appendTo('#image_list');
        $("<p><input type='checkbox' name='revolving' id='element_id' class='background_input element_id' value='revolving'> Revolving</p>").appendTo('#image_list');       
        }
    });
    }
    });

下面的Php检索:

$result = mysqli_query($link, "SELECT * FROM elements WHERE page_id = '$page_id'");

$rows = array();

while ($row = mysqli_fetch_row($result)) {
    $data[] = $row;
}

echo json_encode($data);

下面的JSON输出:

[[ “634”, “1”, “1”, “1”, “检查”, “图像”,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL ,null,“653364494e41b2baeb9f3bd8dd88380f.png”,“test image.jpg”,“extended”,“grayscale”,null,“solid”,“0”,“0”,“0”,“000000”,“0”, “000000”, “0”, “固体”, “1”, “0”,零, “0”, “0”, “0”, “0”, “000000”, “150”, “100”, “388”,“554”,“ - 100”,null,“unchecked”,“2016-03-17 18:31:24”,[“642”,“1”,“1”,“1”, “checked”,“image”,null,null,null,null,null,null,null,null,null,null,null,null,“b320a437bcd56282ca12c06750079ad1.png”,“test image2.jpg”,“normal”,“ RGB”,NULL, “固体”, “0”, “0”, “0”, “000000”, “0”, “000000”, “0”, “固体”, “1”, “0”,无效, “0”, “0”, “0”, “0”, “000000”, “55”, “184”, “321”, “525”, “”,NULL, “未选中”,“2016-03 -17 18:54:40“]]

0 个答案:

没有答案