AJAX терпит неудачу, в то время как данные получаются из цикла while () в php

Когда я использую json_encode($array) я получаю данные правильно, но когда я использую json_encode в массиве, который зациклирован, я получаю следующую ошибку

[object Object] parsererror СинтаксисError: Неожиданный токен {


Я использую ajax для получения json-данных из functions.php

 $(function() { $('#get').click(function(){ $.ajax({ url: 'http://android.ezinfotec.com/functions.php', type : 'GET', data : 'method=getquestions', dataType : 'json', success : function(s) { console.log(s); }, error: function(XMLHttpRequest,textStatus,errorThrown) { console.log(XMLHttpRequest+' '+textStatus+' '+errorThrown); } }); }); }); 

Функции.php

 <?php header('Content-type: application/json'); include("connect.php"); if($_GET['method'] == 'getquestions') { $query = mysql_query("select * from questions"); while($fetch = mysql_fetch_array($query)) { $output = array( "id" => $fetch['id'], "answers" => $fetch['answers'], "status" => $fetch['ans_status'], "postedon" => substr($fetch['month'],0,3).' '.$fetch['day'].' '.$fetch['year'], "question" => $fetch['question'], "category" => $fetch['category'], "parent" => $fetch['parentcategory'], "authorid" => $fetch['author'], "authorname" => $fetch['author_name'] ); echo json_encode($output); } } в <?php header('Content-type: application/json'); include("connect.php"); if($_GET['method'] == 'getquestions') { $query = mysql_query("select * from questions"); while($fetch = mysql_fetch_array($query)) { $output = array( "id" => $fetch['id'], "answers" => $fetch['answers'], "status" => $fetch['ans_status'], "postedon" => substr($fetch['month'],0,3).' '.$fetch['day'].' '.$fetch['year'], "question" => $fetch['question'], "category" => $fetch['category'], "parent" => $fetch['parentcategory'], "authorid" => $fetch['author'], "authorname" => $fetch['author_name'] ); echo json_encode($output); } } 

В приведенном выше PHP-коде, если я удаляю цикл while и просто задаю пользовательские значения для переменной, я получаю идеальные данные на странице html.

Примечание . Нет проблемы с перекрестным доменом, поскольку у меня много функций, кроме getquestions();

Вы можете проверить выход json на странице http://android.ezinfotec.com/functions.php?method=getquestions