Ticket #10778 (closed bug: invalid)
$form.submit() behaving differently between chrome and firefox
| Reported by: | s.shpiz@… | Owned by: | s.shpiz@… |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | event | Version: | |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Consider the following:
var $form = $('<form id="fid" action="/page.php" method="post" target="iframe_name" ><input type="hidden" name="title" value="7" /></form>');
var $iframe = $('<iframe name="iframe_name" ></iframe>');
$('body').prepend($iframe);
$form.submit();
the last line will cause page.php to load in chrome but not in firefox. in firefox it will work if i write $('body').prepend($form); before the submit() command versions: CHROME: 15.0.874.106 m FIREFOX: 7.0.1
this is my first bug report here. hope i'm not spamming you
Change History
comment:1 Changed 19 months ago by dmethvin
- Owner set to s.shpiz@…
- Status changed from new to pending
comment:2 Changed 19 months ago by s.shpiz@…
- Status changed from pending to new
Hi. Here's a jfiddle : http://jsfiddle.net/Q6DaZ/4/ . (behaves differently in brosers: firefox and IE are not like chrome ) You're right, its not a bug with jquery. I'll post this to mozilla or something... I was wondering, however, whether it made more sense to fail to post the form in all browsers or cheat firefox so that it behaves the same for all browsers. It would have saved me time debugging on firefox. maybe it can save others time. (though this is probably isn't a big deal since most forms are on the page to begin with)
Thanks,
Shimon
comment:3 Changed 19 months ago by timmywil
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from new to closed
- Component changed from unfiled to event
I'd recommend attaching the form before submitting. You can make it hidden if necessary. Thanks for looking into this further.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Please post a link to a complete but minimal page that represents a test case, so we don't misinterpret your code snippet. We prefer that people use jsFiddle.net for test cases.
While you're creating a test case, please do the equivalent in bare DOM functions, I suspect the problem may be the browser and not jQuery. For example, your form is not attached to the document and that may not be something that Firefox supports. If the problem occurs in Firefox with only DOM functions and no jQuery, you should file a bug with them.