gpt4 book ai didi

javascript - 当我想以发布方法提交表单时,有什么方法可以将 token 添加到 header 吗?

转载 作者:行者123 更新时间:2023-12-03 04:06:48 24 4
gpt4 key购买 nike

我想要做的是在提交表单中添加要请求的 token 。我怎样才能实现这个目标?这是我的代码,:action 来自 'vue-bind'。

 <form method="post" enctype="multipart/form-data" :action="mainUrl+'/nameList'">
<ol>
<li><a href="http://120.55.113.9:8080/prizesearch-main/file/NameList.xls">download the files</a></li>
<li><input type="file" @change="jsReadFiles" :files="files" ref="inputfile" name="nameListFile"></li>
<li><input type="submit" value="upload the files"></li>
</ol>
</form>

最佳答案

您可以简单地使用 jQuery's beforeSend 回调添加带有身份验证信息的 HTTP header :

beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", token);
},

引用this了解更多信息。

关于javascript - 当我想以发布方法提交表单时,有什么方法可以将 token 添加到 header 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44514161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com