'How to call variabled ajax
I put the ajax call in a variable, how can I call it again and pass some parameters to the data attribute of the ajax?.
var request = $.ajax({
URL: '/usage_analytics.php',
type: 'get',
data: {date_start: dt_date_start, date_end: dt_date_end},
dataType: 'json'
});
request.done(function (r) {
console.log(r);
//my codes goes here
});
now I have a date range picker, If i click apply button i just want to call the request variable to be able to trigger the ajax call again and pass some parameters.
$('#reportrange').on('apply.daterangepicker', function(ev, picker) {
var picked_start = picker.startDate.format('YYYY-MM-DD');
var picked_end = picker.endDate.format('YYYY-MM-DD');
dt_date_start = picked_start;
dt_date_end = picked_end;
//call the request here and pass the dt_date_start and dt_date_end
});
TIA
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
