[英]how to pass variable from html to ajax/javascript
I have below HTML page which I land on after successful authentication.我有以下 HTML 页面,我在成功验证后登陆。 In its body, I get access_token value.
在它的正文中,我得到了 access_token 值。
<html>
<head>
<title>Authorization successful</title>
</head>
<body>
<p>Welcome. You are authorized to access the page.</p>
<p>access_token: {{ access_token }}</p>
<p>token_type: {{ token_type }}</p>
<form method="POST" action="/protected_hi" >
<button type="submit" id="protectedApiButton">Protected API</button>
</form>
<script src="ajax.js"></script>
</body>
</html>
Add the input with the type of hidden to store the access token.添加类型为 hidden 的输入以存储访问令牌。
<input type="hidden" id="access_token" value="token-goes-here" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.