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">
</form>
<script>
$('#my_form').submit();
</script>
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.
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
The
$('#my_form').submit();
will cause a POST action to your webserver, so you need
app.post('/age_page', ....);
to receive the post form action in your backend
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.