I can send a POST request and render the response as a full page via submitting a form. How can I do that via a ajax request? That is:
$.ajax('test', {
'method': 'POST',
'success': function(res) {
// open a new page, render res as a full page
// I can't simply do window.location = "foobar" as it's a POST
}
});
Or, if this is strange, what is the conventional way of doing it?
I can send a POST request and render the response as a full page via submitting a form. How can I do that via a ajax request? That is:
$.ajax('test.', {
'method': 'POST',
'success': function(res) {
// open a new page, render res as a full page
// I can't simply do window.location = "foobar" as it's a POST
}
});
Or, if this is strange, what is the conventional way of doing it?
method="POST"
instead of using script if the result page is html
– mplungjan
Commented
Mar 7, 2015 at 10:47
If you just need to open result of your form processing in new page you don't need ajaxa and you can just use target property of form like
<form action="http://test./" method="post" target="_blank">
Your inputs, etc.
</form>
Well i would go for form if you don't care about response at this point. But if you do, you can check response and do something like this:
$.ajax('test.', {
'method': 'POST',
'success': function(res) {
if ( res.code == 200 )
document.location = 'page1.htm';
else
alert('error!');
}
});