我有这个 HTML 表单
<form name="nextform" action="anotherpage.php" method="post" enctype="multipart/form-data">
<input name="pinid" id="pinid" type="hidden">
<input type="submit" name="submit" id="post" value="Lets Go" class="formButtonMap">
</form>
pinid
使用 JavaScript 动态获取一个值。当它获得一个值时,我会提醒它并且它起作用了。
但是,当我单击 Lets Go
按钮时,没有任何反应。我看到 Internet Explorer 加载了几分钟,然后收到消息“网页没有响应”。如果我点击刷新,它会转到 anotherpage.php
但表单中的值没有到达服务器。
很少显示此消息:
Visual Studio Just-In-Time Debugger
An unhandled win32 exception occured in iexplorer.exe [688]
Possible Debuggers :
New Instance of Microsoft Visual Studio 2012
此行为仅在 Internet Explorer 11.0.2 中出现。该表单适用于旧版本的 Internet Explorer 以及 Chrome 和 Firefox。我在 IE 的控制台中没有收到任何错误。
这是 JavaScript 代码,位于表单上方:
// called when another button is clicked - basicaly is websockets
function save() {
var so = new WebSocket("ws://localhost:8000");
so.onerror = function (evt) {
alert('problem');
}
if (sara == 'LINES') {
so.onopen = function() {
so.send(JSON.stringify({
command: 'insertAll',
name: document.getElementById('name').value
}));
}
}
if (sara == 'POLY') {
so.onopen = function() {
so.send(JSON.stringify({
command: 'insertHalf',
name: document.getElementById('name').value
}));
}
}
so.onmessage = function (evt) {
var received_msg = evt.data;
document.getElementById("next").style.display = "block";
document.getElementById("name").value = "";
document.getElementById("descr").value = "";
clearLinks();
document.getElementById("pinid").value = received_msg;
alert(document.getElementById("pinid").value); // works
so.close();
}
}
我尝试使用 document.getElementById("nextform").submit();
编辑代码,问题仍然存在。
是我吗?这是一个错误吗?我错过了什么?
最佳答案
我认为这是在 IE 中将表单值设置为空时的错误。
我建议尝试一种不同的方法来重置表单值,我过去使用过这种方法:
document.getElementById('name').parentNode.innerHTML = '';
关于javascript - IE 11 无法提交 HTML 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20723776/