我有一个代码可以下载CSV文件,并且工作正常,但是我想知道是否有一种方法可以改善我的代码。该下载应自动下载,该代码在Jquery中为我的URL做什么,它将作为请求传递给服务器的内容下载。同时,在浏览器中,我的datetimepicker与我的URL的Ajax请求不相关。
<div class='col-md-4'>
<div class="form-group">
<div class='input-group date' id='datetimepicker7'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
<!---Downloading File using
Jquery with Buttons---->
<div class="form-group"><br>
<div class="col-md-1.9 text-center">
<button id="download" name="download" class="btn btn-warning" >Download</button><br>
</div>
</div>
// date functionality
$(document).ready(function() {
$(function() {
$('#datetimepicker6').datetimepicker();
$('#datetimepicker7').datetimepicker({
useCurrent: false
});
$("#datetimepicker6").on("dp.change", function(e) {
$('#datetimepicker7').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker7").on("dp.change", function(e) {
$('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
});
});
});
// Downloading file into zip file.
$(document).ready(function() {
$("#download").click(function() {
window.location.href ='https://api.thingspeak.com/channels/899906/feeds.csv?start=2019-11-12%2019:11:12&end=2019-11-13%2019:11:13';
});
});