The following syntax works on Safari (osx), Chrome (win/osx), and Firefox (win/osx) - but does NOT work on non-metro IE 11 (windows 8.1).
var html = '<form id="theForm" name="theForm" action="/controller/action" method="POST">;
html += '<input type="hidden" name="bob" value="-1" />';
html += '</form>';
// I expect this to work in IE as it does in all other browsers.
$(document).add(html).submit();
Is this a bug or have I done something incorrect?
It looks like you are having some chaining issues. I think you want to append your html
string to the body
element (not document
), and submit form
element. You are on the right track with $('BODY').append(html).sumbit();
, but the submit
is being called on the body
element, rather than the form
element.
Instead, create a jQuery object collection from the html
string, append it to the body
, then submit
it.
$(html).appendTo('body').submit();
var html = '<form id="theForm" name="theForm" action="/controller/action" method="POST">';
html += '<input type="hidden" name="bob" value="-1" />';
html += '</form>';
$(html).appendTo('body').submit();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.