【发布时间】:2019-09-12 03:54:24
【问题描述】:
我添加了用于选择日期的脚本,并在单击应用按钮时我想调用一个 ajax 来获取数据。但它不起作用。当代码到达 ajax 时它会停止并且在控制台中我得到了这个错误。
我将数据作为 POST 发送,但在我的控制器中我刚刚收到了令牌。并且日期范围未传递给控制器。
TypeError: e is undefined
我的代码如下。
$('.search_dashboard_data').daterangepicker({
autoUpdateInput: false,
locale: {
cancelLabel: 'Clear'
}
});
function ajaxCallForSearchedData(searched_date)
{
//console.log(searched_date);
$.ajax({
type: 'POST',
url: '{{ route('agent.get_searched_dashboard_data') }}',
data: {
'date_range': searched_date,
"_token": "{{ csrf_token() }}",
},
success: function (result) {
console.log('result' + result);
$('#all_fees_data').hide();
$('#searched_fees_data').html(result);
$('#all_time').hide();
$('#day').hide();
$('#week').hide();
$('#month').hide();
$('#searched_fees_data').show();
}
});
}
$('.search_dashboard_data').on('apply.daterangepicker', function(ev, picker) {
/*$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));*/
/*alert($(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY')));*/
var searched_date = $(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
ajaxCallForSearchedData(searched_date);
});
【问题讨论】:
-
这个函数在哪里调用 ajaxCallForSearchedData(searched_date)
标签: jquery laravel daterangepicker