我正在使用 daterangepicker.js,在更改日期时,当我更改需要调用 getchart() 的日期时,我必须调用 getchart 方法,任何人都可以帮助我,这是我的代码:
$(document).ready(function() {
$('#dateRangeSelector').daterangepicker(); //textbox id
var start = Date.today().setTimeToNow();
var end = Date.today().setTimeToNow();
var displayValue = start.toString("yyyy/MM/dd") + " - " + end.toString("yyyy/MM/dd");
$('#dateRangeSelector').val(displayValue);
var host = '<?=$host ?>'
var dateRangeSelector = $("#dateRangeSelector").val();
var dates = dateRangeSelector.split(" - ");
var value = "'"+dates.join("' , '")+"'";
var array = value.split(',');
var startTime = array[0];
var endTime = array[1];
$.get(SITE_URL + 'admin/SystemMonitor/charts/getChartsData', {'host' : host,'startTime' : startTime,'endTime' : endTime}, function(response){
console.log("viewCharts", response);
obj = response;
//bootbox.alert(obj.status, obj.label);
if (obj.status == 'OK') {
$('.one_half').show();
showMonitoringServer(host, obj);
} else {
show_message('Show Chart Error -' +host, 'Unexpected error occured! Please try again later!', 'error' );
}
}, "json");
});