Reputation: 2450
I've implemented the following code:
function post(path, params) {
var form = document.createElement('form');
form.setAttribute('target', '_blank');
form.setAttribute('method', 'post');
form.setAttribute('action', path);
var hiddenField = document.createElement('input');
hiddenField.setAttribute('name', 'JSON');
hiddenField.setAttribute('type', 'submit');
hiddenField.setAttribute('value', JSON.stringify(params));
form.appendChild(hiddenField);
form.submit();
}
It works wonderfully in chrome, safari, and IE but does nothing when using firefox.
any ideas what the problem could be?
Upvotes: 1
Views: 79
Reputation: 943922
You need to put the form in the DOM of the page before Firefox will submit it.
document.body.appendChild(form);
form.submit();
… should do the trick.
Upvotes: 2