GET方式请求下载时总是要对中文进行编码,然后后台再解码比较繁琐,POST方式主要通过js构建表单属性
download:function () {
//下载 post方式
$("#downloadform").remove();
var form=$("<form>");
form.attr("id","downloadform");
form.attr("style","display:none");
form.attr("target","");
form.attr("method","post");
form.attr("action", "${base}/smarteye/downloadCSV.htm");
var input1=$("<input>");
input1.attr("type","hidden");
input1.attr("name","userId");
input1.attr("value",$('#userId').val());
form.append(input1);
var input2=$("<input>");
input2.attr("type","hidden");
input2.attr("name","userName");
input2.attr("value",$('#userName').val());
form.append(input2);
var input3=$("<input>");
input3.attr("type","hidden");
input3.attr("name","roleName");
input3.attr("value",$('#roleName').val());
form.append(input3);
$("body").append(form);
form.submit();
}
网友评论