【发布时间】:2014-01-10 12:07:45
【问题描述】:
我有这个 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 即时调试器
iexplorer.exe [688] 中出现未处理的 win32 异常
可能的调试器:
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(); 编辑代码,问题仍然存在。
是我吗?它是一个错误吗?我错过了什么?
【问题讨论】:
-
为什么在提交输入中需要一个值?
-
@w3jimmy 这是用户看到的文本的“名称”。它可以是“下载”或“返回”。你建议我删除它?
-
如果您看到,您的页面实际上会发布,所以问题似乎不在于按钮本身。重定向页面可能有问题吗?
-
既然你没有上传文件,不妨试试不带 enctype="multipart/form-data"?
-
根据描述,问题很可能出在
anotherpage.php,将您的表单发布到另一个(最好是空的)页面,看看它是否也一样。同时发布anotherpage.php的代码也会有所帮助。
标签: javascript html forms internet-explorer internet-explorer-11