美文网首页
POST发起下载请求

POST发起下载请求

作者: 马木木 | 来源:发表于2018-07-21 11:28 被阅读0次

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();


        }

相关文章

网友评论

      本文标题:POST发起下载请求

      本文链接:https://www.haomeiwen.com/subject/ukchmftx.html