I am using following javascript function to construct a form and submitting it to the server. It works fine in Chrome browser but not working in Firefox.
function loadPage(url, projectName){
var jForm = $('<form></form>');
jForm.attr('action', url);
jForm.attr('method', 'post');
var jInput = $("<input>");
jInput.attr('name', 'curPrj');
jInput.attr('value', projectName);
jForm.append(jInput);
jForm.submit();
}
I got some suggestion from SE's older post Mozilla form.submit() not working, to append the form to document body document.body.appendChild(jForm)
but unfortunately that didn't work for me either. I got following error in debug console when I used document.body.appendChild(jForm)
before form submit.
TypeError: Argument 1 of Node.appendChild does not implement interface Node. @ http://localhost:9000/assets/javascripts/global.js
Am I missing something here? Pls advise.