POST 接收时内容为空
POST content is empty at reception
我有一个字符串,我想通过隐藏输入从 JS 传递到 PHP,但是 POST 形式在到达时没有 return 任何东西(我检查过它var_dump($_POST)
),这在我身上从来没有发生过。
这是我的 HTML 代码:
<form action='' id='hash-form'>
<input type='hidden' id='hash' name='hash'/>
</form>
这里是我改值提交的JS代码:
document.getElementById("hash").value = content;
console.log(document.getElementById("hash").value);
document.getElementById("hash-form").submit();
提前致谢!
表单缺少 method
属性,因此默认为 GET,而不是 post。
将 method="POST"
添加到 form
标签中。
我有一个字符串,我想通过隐藏输入从 JS 传递到 PHP,但是 POST 形式在到达时没有 return 任何东西(我检查过它var_dump($_POST)
),这在我身上从来没有发生过。
这是我的 HTML 代码:
<form action='' id='hash-form'>
<input type='hidden' id='hash' name='hash'/>
</form>
这里是我改值提交的JS代码:
document.getElementById("hash").value = content;
console.log(document.getElementById("hash").value);
document.getElementById("hash-form").submit();
提前致谢!
表单缺少 method
属性,因此默认为 GET,而不是 post。
将 method="POST"
添加到 form
标签中。