Я пытаюсь отправить от Laravel ответ на запрос AJAX.AJAX Отправить массив как ответ от Laravel
public function infoRoute(Request $request)
{
// Get info
$ship_id = $request->ship_id;
$startDate = $request->datepicker_start;
$endDate = $request->datepicker_end;
// Get all the locations between those dates
$routeArray = $this->measurementRepository->getCoordinates($ship_id, $startDate, $endDate);
$ship = $this->shipRepository->getShipForId($ship_id);
$info = $this->createRouteArrayForShip($ship, $routeArray);
if($request->ajax()) {
return response()->json(json_encode($info));
}
}
protected function createRouteArrayForShip($ship, $routeArray)
{
$info['type'] = "showRoute";
$index = 0;
foreach($routeArray as $coordinates)
{
$info['info']['route']['loc'. $index] = $coordinates;
$index++;
}
$info['info']['shipInfo'] = $ship;
//dd($info);
return $info;
}
Когда я получаю информацию и обрабатываю ее с помощью jQuery, все показывает, кроме пустого маршрута.
Спасибо,
если вы используете браузер инструменты для разработчиков .. Какие данные вы видите, возвращаясь в ответ? – Dale
У вас есть многомерный массив там .. –
Попробуйте вернуть его как JSON – kejsu