I'm trying to pass two variables to my ajax success response so that i can use them in a some html to display on the page. As you can see i've tried passing them as an array but it ends up empty. How do i pass both php variables and access them in my ajax success call?
//show datpicker calendar set function on select
$( "#datepicker" ).datepicker({
numberOfMonths: 1,
showButtonPanel: true,
dateFormat: "yy-mm-dd",
onSelect: getDate
});
function getDate(response){
var selectedDate = $('#datepicker').val();
var values = {'selectedDate': selectedDate };
$.ajax({
url: '/reservations/admin/dateRequest',
type: 'POST',
data: values,
dataType: 'json',
success: function (response) {
.....use response data here....
} //end success
});//end ajax call
return false;
}
My PHP
public function differentDate() {
//get selected date from datepicker selection
$selectedDate = $_POST['selectedDate'];
//convert the selected date to carbon element
$ConvertedSelectedDate = new Carbon($selectedDate);
//find day of week based on selection/conversion
$dayOfWeek = $ConvertedSelectedDate->dayOfWeek;
$times = ReservationTimeSlot::where('day_of_week', '=', $dayOfWeek)->get();
$parties = Party::where('date', '=', $ConvertedSelectedDate)->get();
$response = ['times' => $times, 'parties' => $parties];
return $response;
}
all of this gives me empty arrays
{"times":{},"parties":{}}