This snippet creates html form and submits it, the same way as browser submits form "with redirect". If you need the redirect not an ajax solution, for example credit card payment.
Source code viewer
function createAndPostHtmlForm(path, params) { var form = document.createElement('form'); form.setAttribute('method', 'post'); form.setAttribute('action', path); for (var key in params) { if (params.hasOwnProperty(key)) { var hiddenField = document.createElement('input'); hiddenField.setAttribute('type', 'hidden'); hiddenField.setAttribute('name', key); hiddenField.setAttribute('value', params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); }, /* Usage: */ createAndPostHtmlForm('https://example.com/submit.php', { field1: 'value1', field2: 'value2' });Programming Language: Javascript