Jquery Form.submit() on Chrome works but not in Firefox
form-submit, javascript, jquery, onclick
Solution
I would try adding the form to the DOM before submitting.
$('#content-tab .submit').click(function() {
var data = {
champion: window.selectedChampion,
runes: runes,
masteries: masteries,
items: items,
skillingOrders: skillingOrders,
chapters: chapters,
title: $('#guide_title').val()
};
data = JSON.stringify(data);
var $form = $("<form method='post'>").append($('<input type="hidden" name="data" id="data">').val(data));
$form.appendTo("body").submit();
});
Problem
I have the following function that collects data from a page, stuffs them all into the 'data' variable, appends it to a form then submits it. ``` $(document).ready(function () { $('#content-tab .submit').click(function () { var data = {champion: window.selectedChampion, runes: runes, masteries: masteries, items: items, skillingOrders: skillingOrders, chapters: chapters, title: $('#guide_title').val()}; data = JSON.stringify(data); $("<form method='post'>").append($('<input type="hidden" name="data" id="data">').val(data)).submit(); }); }); ``` There is a div on the page that triggers this when clicked on: ``` <div class='button pointer submit'>Submit</div> ``` All is well when tested in Chrome. The form submits then redirects to a page, just as planned. But while testing in Firefox (v. 5 and 6), clicking on the div does nothing. Nada. Zilch. I wonder what went wrong in Firefox? Any help would be highly appreciated. Thank you.