Jack Johnson Jack Johnson - 1 year ago 165
HTML Question

Node.js - POST to iFrame?

So I have this site that I need to post some data to. That site will be in an iFrame and the data that I'm posting is in my markup.

<iframe src="www.externalsite.com/whatever.php" name="my_iframe"></iframe

<form id="my_form" target="my_iframe">
<input type="hidden" name="age" value="12">
<input type="hidden" name="name" value="bob">


I have a route that renders this page in node like this:

app.get('/age_page', function() {
res.render('age_page.html', res);

What is the correct way to send the data from my_form to the iframe so it renders the correct content inside my iframe? The iframe is just going to consume that data and store it in a database.

Answer Source

In your example, the iframe does not appear to be connected with the form in any way, so not sure how the iframe is relevant, but



will cause a POST action to your webserver, so you need

app.post('/age_page', ....);

to receive the post form action in your backend

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download