๋ฐ์ํ
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", '/comp');
const params = {'uid': uid}
//ํ๋ ์ผ๋ก ๊ฐ์ ์ฃผ์
์ํจ๋ค.
for(var key in params) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
document.body.appendChild(form);
form.submit();
function post_to_url(path, params, method) {
method = method || "post"; // ์ ์ก ๋ฐฉ์ ๊ธฐ๋ณธ๊ฐ์ POST๋ก
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
//ํ๋ ์ผ๋ก ๊ฐ์ ์ฃผ์
์ํจ๋ค.
for(var key in params) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
document.body.appendChild(form);
form.submit();
}
์ฌ์ฉํ ๋๋
<a href="javascript:post_to_url('www.XXXX.com/XXXXhtml',{'type1':'aaa','type2':'bbb'})">POST๋ณด๋ด๊ธฐ</a>
flask์์ form๋ฐ๊ธฐ
@app.route('/post', methods=['POST'])
def post():
value = request.form['test']
return value
๋ฐ์ํ
'Web > JavaScript' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
TypeError: axios is not a function ์ค๋ฅ ๋ฐ์ (0) | 2022.10.07 |
---|---|
MathJax, ๊ณฑํ๊ธฐ ์ ๋ ฅ (0) | 2020.12.03 |
์น์์ OAuth 2.0 ์ฌ์ฉํ๊ธฐ (Google) (0) | 2020.09.21 |
[Javascript] MathJax - ์ํ ๊ธฐํธ ์ฐ๊ธฐ (0) | 2020.08.12 |
์์ซ์ ๋ฐ์ฌ๋ฆผ (0) | 2020.08.06 |