jQuery 如何在 JavaScript 中的 HTTP 标头中传递 X-Auth-Token
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19928168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pass X-Auth-Token in the HTTP header in JavaScript
提问by GibboK
I have a website which uses Token-based authentication. At first, username and password are sent to log the user in and receive the token. For subsequent calls, I need to include the token as X-Auth-Token
in HTTP header.
我有一个使用基于令牌的身份验证的网站。首先,发送用户名和密码以登录用户并接收令牌。对于后续调用,我需要X-Auth-Token
在 HTTP 标头中包含令牌。
I would like to know how to do that, in vanilla JavaScript or using jQuery. Could you please provide me a sample of code?
我想知道如何在 vanilla JavaScript 或使用 jQuery 中做到这一点。你能给我提供一个代码示例吗?