//实现步骤:
//1.给下载元素添加点击事件
//2.创建form标签
//3.通过input的type="hidden"来传递后台需要的参数
//4.借助form的submit方法提交数据到后台实现下载功能
<button class="downResult">下载</button>
$(".downResult").off('click').on('click',function(){
var $eleForm = $("<form method='get'></form>");
var tempInput = "<input type = 'hidden' name = 'clearStartDate' value = '"+timeStart+"' />"
+"<input type = 'hidden' name = 'clearEndDate' value = '"+timeEnd+"' />"
+"<input type = 'hidden' name = 'parkOperatorType' value = '"+parkOperatorType+"' />"
+"<input type = 'hidden' name = 'parkName' value = '"+parkName+"' />"
;
$eleForm.append(tempInput);
$eleForm.attr("action", serverUrl+"parkClearing/exportParkClearingData");
$(document.body).append($eleForm);
$eleForm.submit();
$eleForm.remove();
});
网友评论