I am using nodejs and the framework express.js to realize my website.
I am submitting a POST request on an url (/report/reportname) reportname is a variable.
so I do this :
app.post('/report/:id', function(req, res){
var id=req.param('id');
var bodyreportHtml;
go.prototype.runReport(id,res);
}
The thing is that in go.prototype.runReport(id,res)
I do a res.send(bodyofthereport)
.
So when I click on submit on my form that just redirect me on /report/nameofthereport
where the pdf report is.
Everything is working but I would like to put this url /report/nameofthereport
(the pdf report) in an iframe.
So when I submit the post request I want it just refresh the iframe and print the report in it ( the iframe is on the same page than the form).
But the res.send(bodyofthereport)
is essential : it prints my report at /report/nameofthereport
And I can't do a res.redirect('/')
because the body is finished
How can I do ?
Thanks !
If you want to POST
to an iframe, you could just set the target
attribute of the form
to the name of the iframe:
<form action='/report/ID' method='POST' target='FOO'></form>
<iframe name='FOO'></iframe>
Nothing node.js or Express specific about this!