Я пытаюсь получить свои данные JSON от Symfony, но, похоже, они работают неправильно.Ниже приведен фрагмент кода Symfony:
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
return $this->renderPartial('listJsonResponse',
array('jsonSlots' => json_encode($this->jsonQuery)));
Вышеприведенный код работает нормально и соответствует частичному.Все, что в моей части - это:
<?php echo $jsonSlots ?>
Теперь, согласно Firebug, это заполняется правильно.Ниже приведена копия ответа
[{ "ID": "1", "schedule_day": "start_time" "ПН": "9:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "2"},{ "ID": "2", "schedule_day": "пН", "start_time": "9:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "3", "schedule_day": "ПН", "start_time": "9:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "4", "schedule_day": "пН", "start_time": "9:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "5", "schedule_day": "ПН", "start_time": "10:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "6", "schedule_day": "ПН", "start_time": "10:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "7", "schedule_day": "пН", "start_time": "10:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "8", "schedule_day": "ПН", "start_time": "10:45:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "9", "schedule_day": "пН", "start_time": "11:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "10", "schedule_day": "ПН", "start_time": "11: 15: 00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "11", "schedule_day": "Ср", "start_time": "11:30:00" "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "12", "schedule_day": "ПН", "start_time": "11:45:00"," concurrent_appointments":" 2" , "CURRENTCOUNT": "0"}, { "идентификатор": "13", "schedule_day": "ПН", "start_time": "12:00:00", "concurrent_appointments": "2" "CURRENTCOUNT": "0"}, { "идентификатор": "14", "schedule_day": "пН", "start_time": "12:15:00", "concurrent_appointments": "2"," CURRENTCOUNT":" 0 "}, {" идентификатор ":" 15" , "schedule_day": "ПН", "start_time": "12:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, {" идентификатор ":" 16" , "schedule_day": "ПН", "start_time": "12:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, {"идентификатор": "17", "schedule_day": "ПН", "start_time": "13:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор":"18", "schedule_day": "ПН", "start_time": "13:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "19","schedule_day": "ПН", "start_time": "13:30:00", "concurrent_appointments": "2", "токГраф ":" 0 "}, {" идентификатор ":" 20" , "schedule_day": "ПН", "start_time": "13:45:00", "concurrent_appointments": "2", "CURRENTCOUNT":»0 "}, {" ID ":", "schedule_day 21" ": "", "start_time пн": "14:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"},{ "идентификатор": "22", "schedule_day": "ПН", "start_time": "14:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "23", "schedule_day": "пН", "start_time": "14:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "24", "schedule_day": "ПН", "start_time": "14:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "25", "schedule_day": "ПН", "start_time": "15:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "26", "schedule_day": "ПН", "start_time": "15:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "27", "schedule_day": "ПН", "start_time": "15:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "28", "schedule_day": "Ср", "start_time": "15:45:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "29", "schedule_day": "Ср", "start_time ":" 16:00:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "30", "schedule_day": "ПН", "start_time":»16:15:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "31", "schedule_day": "Ср", "start_time": "16:30:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "32", "schedule_day": "ПН", "start_time": "16:45:00",»concurrent_appointments ":" 2" , "CURRENTCOUNT": "0"}, { "идентификатор": "33", "schedule_day": "ПН", "start_time": "17:00:00", "concurrent_appointments":»2" , "CURRENTCOUNT": "0"}, { "идентификатор": "34", "schedule_day": "пН", "start_time": "17:15:00", "concurrent_appointments": "2",»CURRENTCOUNT ":" 0 "}, {" идентификатор ":" 35" , "schedule_day": "ПН", "start_time": "17:30:00", "concurrent_appointments": "2", "CURRENTCOUNT":»0 "}, {" идентификатор ":" 36" , "schedule_day": "ПН", "start_time": "17:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}]
Обратите внимание, что если я уберу заголовок Content / Type, он немного изменится.Я получаю ту же вкладку ответа, что и выше, но также вкладку html с вышеупомянутым, разобранным в html.Который показывает так:
[{ "ID": "1", "schedule_day": "start_time" "ПН": "9:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "2"},{ "ID": "2", "schedule_day": "ПН", "start_time": "9:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "3", "schedule_day": "пН", "start_time": "9:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "4", "schedule_day": "пН", "start_time": "9:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "5", "schedule_day": "пН", "start_time": "10:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "6", "schedule_day": "пН", "start_time": "10:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "7", "schedule_day": "ПН", "start_time": "10:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "8", "schedule_day": "ПН", "start_time": "10:45:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "9", "schedule_day": "пН", "start_time": "11:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "10", "schedule_day": "ПН", "start_time": "11: 15: 00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "11", "schedule_day": "Ср", "start_time": "11:30:00" "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "12", "schedule_day": "ПН", "start_time": "11:45:00"," concurrent_appointments":" 2" , "CURRENTCOUNT": "0"}, { "идентификатор": "13", "schedule_day": "ПН", "start_time": "12:00:00", "concurrent_appointments": "2" "CURRENTCOUNT": "0"}, { "идентификатор": "14", "schedule_day": "пН", "start_time": "12:15:00", "concurrent_appointments": "2"," CURRENTCOUNT":" 0 "}, {" идентификатор ":" 15" , "schedule_day": "ПН", "start_time": "12:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, {" идентификатор ":" 16" , "schedule_day": "ПН", "start_time": "12:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, {"идентификатор": "17", "schedule_day": "ПН", "start_time": "13:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор":"18", "schedule_day": "ПН", "start_time": "13:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "19","schedule_day": "ПН", "start_time": "13:30:00", "concurrent_appointments": "2", "токГраф ":" 0 "}, {" идентификатор ":" 20" , "schedule_day": "ПН", "start_time": "13:45:00", "concurrent_appointments": "2", "CURRENTCOUNT":»0 "}, {" ID ":", "schedule_day 21" ": "", "start_time пн": "14:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"},{ "идентификатор": "22", "schedule_day": "ПН", "start_time": "14:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "23", "schedule_day": "пН", "start_time": "14:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "24", "schedule_day": "ПН", "start_time": "14:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "25", "schedule_day": "ПН", "start_time": "15:00:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "26", "schedule_day": "ПН", "start_time": "15:15:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "27", "schedule_day": "ПН", "start_time": "15:30:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "28", "schedule_day": "Ср", "start_time": "15:45:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "29", "schedule_day": "Ср", "start_time ":" 16:00:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "30", "schedule_day": "ПН", "start_time":»16:15:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "ID": "31", "schedule_day": "Ср", "start_time": "16:30:00" , "concurrent_appointments": "2", "CURRENTCOUNT": "0"}, { "идентификатор": "32", "schedule_day": "ПН", "start_time": "16:45:00",»concurrent_appointments ":" 2" , "CURRENTCOUNT": "0"}, { "идентификатор": "33", "schedule_day": "пН", "start_time": "17:00:00", "concurrent_appointments":»2" , "CURRENTCOUNT": "0"}, { "идентификатор": "34", "schedule_day": "ПН", "start_time": "17:15:00", "concurrent_appointments": "2",»CURRENTCOUNT ":" 0 "}, {" идентификатор ":" 35" , "schedule_day": "ПН", "start_time": "17:30:00", "concurrent_appointments": "2", "CURRENTCOUNT":»0 "}, {" идентификатор ":" 36" , "schedule_day": "пН", "start_time": "17:45:00", "concurrent_appointments": "2", "CURRENTCOUNT": "0"}]
Я знаю, что функция JSON срабатывает, но она не анализирует функцию успеха и не предупреждает меня о каких-либо данных.JavasScript показан ниже и обернут в тег jquery ready
$.getJSON('/frontend_dev.php/module/listJSONSlots', function(data) {
alert(data);
});
Есть идеи, почему я не могу получить предупреждение?