Skip to content

IE fix if form is in a different document #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@
s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
id = 'jqFormIO' + (new Date().getTime());
var ownerDocument = form.ownerDocument;
var $body = $form.closest('body');
if (s.iframeTarget) {
$io = $(s.iframeTarget);
$io = $(s.iframeTarget, ownerDocument);
n = $io.attr2('name');
if (!n) {
$io.attr2('name', id);
Expand All @@ -418,7 +420,7 @@
}
}
else {
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />', ownerDocument);
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
}
io = $io[0];
Expand Down Expand Up @@ -597,11 +599,11 @@
// if using the $.param format that allows for multiple values with the same name
if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
extraInputs.push(
$('<input type="hidden" name="'+s.extraData[n].name+'">').val(s.extraData[n].value)
$('<input type="hidden" name="'+s.extraData[n].name+'">', ownerDocument).val(s.extraData[n].value)
.appendTo(form)[0]);
} else {
extraInputs.push(
$('<input type="hidden" name="'+n+'">').val(s.extraData[n])
$('<input type="hidden" name="'+n+'">', ownerDocument).val(s.extraData[n])
.appendTo(form)[0]);
}
}
Expand All @@ -610,7 +612,7 @@

if (!s.iframeTarget) {
// add iframe to doc and submit the form
$io.appendTo('body');
$io.appendTo($body);
}
if (io.attachEvent) {
io.attachEvent('onload', cb);
Expand Down