【发布时间】:2021-11-27 16:37:49
【问题描述】:
我使用带有action="/sact/${searchp}/" 的post GET 请求来提交用户搜索查询。
var searchp = search.querySelector("input.search-input").value;
// returns the normal value
document.body.innerHTML += `<form id="jsForm" action="/sact/${search}/" method="GET"><input type="hidden" name="a" value="a"></form>`;
document.getElementById("jsForm").submit();
这里重定向:
router.get('/sact/:where', async (req, res, next) => {
res.render('search');
});
我不明白为什么 /?a=a 每次提交时都会添加到 URL 的后面。如何删除它?
【问题讨论】:
-
如果您在提交表单后不想在 URL 中包含任何查询字符串,请使用
POST而不是GET方法
标签: javascript node.js forms url get