我使用 post GET 請求action="/sact/${searchp}/"來提交用戶搜索查詢。
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 的后面。如何洗掉它?
uj5u.com熱心網友回復:
當您document.getElementById("jsForm").submit();將 URL 上的表單作為查詢引數發送時,因為您正在使用method="GET"
該a=a是這個領域<input type="hidden" name="a" value="a">是隱藏的HTML,但仍然會在URL上發
如果您想“隱藏”您可以使用method="POST"的 URL 將不可見
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/311240.html
標籤:javascript 节点.js 形式 网址 得到
