23

I have a form on a page, something simple like:

<form action="form/submit" method="post">
    <button type="submit">Submit</button>
</form>

It works in every single browser, including older versions of IE, BUT in IE11 it fails, with the tab stuck in a continuous loading loop, never changing to the "thank you" page after submission. HOWEVER, if I open the console, it DOES work.

I'm aware of the console.log issues IE has, and already am using:

if (!window.console) {
    console = {
        log: function() {}
    };
}

to avoid it, which seems to be doing fine (as mentioned, every other IE works). Any insight as to where the issue might lie?

Brian
  • 2,819
  • 4
  • 24
  • 30
  • Are you using JavaScript for the `onsubmit` event? Or is this just a "normal" form? – gen_Eric Nov 22 '13 at 16:32
  • 1
    Are you sure compatibility mode is `off`? Sometimes when opening the Developer Console IE changes how the page renders and works. – Nunners Nov 22 '13 at 16:37
  • `console` has more functions than just `log`, depending on your browser. Maybe you're hitting an Error somewhere? – Halcyon Nov 22 '13 at 16:44
  • @RocketHazmat $("form").submit is being used. – Brian Nov 22 '13 at 17:02
  • @Nunners I see it running in Edge (document mode), not sure if there's any other compatibility options? – Brian Nov 22 '13 at 17:03
  • @Brian: Is that to trigger the submission or to bind to the `onsubmit` event? Can you show that JavaScript code? It may be helpful. – gen_Eric Nov 22 '13 at 17:03
  • @FritsvanCampen log is the only one used in the JS – Brian Nov 22 '13 at 17:04
  • @RocketHazmat Unfortunately I don't think I can share this code, however there are no onsubmit's in the JS, I do see a "try $.post" (with .done/.fail's and a catch) though, does that give enough insight to the submit process? – Brian Nov 22 '13 at 17:07
  • @Brian: So... you didn't write this code, then? Where is the `$.post`? Is that inside a `$("form").submit(function(){` (or `.on('submit', function(){`)? – gen_Eric Nov 22 '13 at 17:55
  • -1 for not posting code that can reproduce the issue. Even if you can't post your code you should be able to post a link to a fiddle that can reproduce the issue. – Mgetz Dec 05 '13 at 21:37

8 Answers8

32

The problem appears when a form only has input elements without a name attribute (or no input elements). I found a reference to the bug here, though it also happens in desktop mode and not just metro mode as the link claims:

http://connect.microsoft.com/IE/feedback/details/807447/ie-11-metro-version-submitting-form-fails-if-input-tag-has-no-name-attribute

The fix is to create a dummy <input type="hidden" name="dummy" value="something"> field (with a name and value set) before submitting the form.

The bug happens in all compatibility modes offered by IE11.

pilif
  • 12,548
  • 5
  • 34
  • 31
11

I just spent WAY too much time on this bug. The crazy part is, IE11 allow the form submission if you have the dev tools (f12) open. This is what I put before my submit button:

<input type="hidden" name="ie11sux" id="ie11sux" value="<?php echo md5(microtime()."ie11sux"); ?>"/>
punkbyte
  • 206
  • 2
  • 3
10

It's a bug in IE11. You can fix it if you add a name attribute to the button, like:

<button type="submit" name="foo" ...
Alex Baban
  • 11,312
  • 4
  • 30
  • 44
7

A form without named element will result in an infinite loop on submit on IE11 + W8.1. To fix that, simply add an attribute name to the button:

<form action="form/submit" method="post">
  <input type="submit" name="cm" value="Submit">
</form>
Toto
  • 2,329
  • 22
  • 40
4

This doesn't directly relate to OP's question, but is an IE-only form submission issue:

If you happen to set form.prop('disabled', true) during the submit event, other browsers will still send the form data, but IE will not - it'll send an empty request body.

Kevin Qi
  • 3,220
  • 2
  • 22
  • 24
  • About to check this - but it sounds like the exact sort of issue I'm currently battling! – Mark Feb 16 '18 at 03:05
0

For me, I had empty hidden fields that were marked required. Pretty stupid but it was the solution that worked for me.

Jake Cattrall
  • 461
  • 4
  • 20
0

For IE11, there is :

event.returnValue = false;

Checking if event.preventDefault exists prevent an eventual error :

event.preventDefault ? event.preventDefault() : (event.returnValue = false);
DependencyHell
  • 1,027
  • 15
  • 22
-1

Your problem is caused by a issue with .net 4 on server side. Please read this: 'WebForm_DoPostBackWithOptions' is undefined in IE11 Preview

You can enable your IE debug function and try submit, you may see the error: WebForm_DoPostBackWithOptions

I fixed a similar submit problem for IE11 by patch this: http://support.microsoft.com/kb/2836939

Community
  • 1
  • 1
Feng
  • 83
  • 6