- 注册时间
- 2013-3-14
- 最后登录
- 2024-11-11
- 阅读权限
- 10
- 积分
- 1550
- 精华
- 0
- 帖子
- 208
|
本帖最后由 joyoes 于 2021-10-31 20:39 编辑
JS动态创建表单post提交怎么设置请求头authorization啊?
在导出xls时,我需要设置请求头的token,但不知道怎么设置呢
- headers:{
- 'authorization':Authorization
- },
复制代码
- function DownLoad(url, fields, callback) {
- //创建Form
- var submitfrm = document.createElement("form");
- submitfrm.action = url;
- submitfrm.method = "post";
- submitfrm.target = "_blank";
- document.body.appendChild(submitfrm);
- if (fields) {
- for (var p in fields) {
- var input = mini.append(submitfrm, "<input type='hidden' name='" + p + "'>");
- var v = fields[p];
- if (typeof v != "string") v = mini.encode(v);
- input.value = v;
- }
- }
- submitfrm.submit();
- setTimeout(function () {
- submitfrm.parentNode.removeChild(submitfrm);
- if (callback) callback();
- }, 1000);
- }
复制代码
|
|