I have a date picker and I put a jquery listener to it on change:
$('#viewmonth').datepicker({language: 'ja', autoclose: true, minViewMode: 'months', format: $('#month_format').text(),}) .change(function() { let date = $(this).datepicker("getDate"); let month = date.getMonth() + 1; date = date.getFullYear() + '-' + month; $.ajax({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}, type:'GET', url:'/head/sale/h_2_501/changeMonth', data: {'viewmonth': date} }); }); When the date is changed, it redirects to changeMonth function:
public function changeMonth() { $viewmonth = date("Y-m-d", strtotime(Request::input('viewmonth'))); $viewmonth = mb_convert_kana($viewmonth, 'a'); error_log($viewmonth); $filter = $this->pageInfo['filter']; $filter['viewmonth'] = $viewmonth; $this->updateFilterData($filter); return redirect()->route('head.sale.h_2_501'); } Inside this function, I am changing the date of the query I use to display some data. The problem is after redirecting to the index route inside changeMonth, the results display doesn't change but the query changed. How do I also update the data displayed?
changeMonth()via AJAX so the response will be returned to your$.ajax()caller (via thesuccesscallback ordonemethod). You don't appear to be attempting to handle the response at all