I have a javascript app that sends ajax POST requests to a certain URL. Response might be a JSON string or it might be a file (as an attachment). I can easily detect Content
Here is my solution using a temporary hidden form.
//Create an hidden form var form = $('', {'method': 'POST', 'action': this.href}).hide(); //Add params var params = { ...your params... }; $.each(params, function (k, v) { form.append($('', {'type': 'hidden', 'name': k, 'value': v})); }); //Make it part of the document and submit $('body').append(form); form.submit(); //Clean up form.remove();
Note that I massively use JQuery but you can do the same with native JS.