[英]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中,而我要发布的数据位于我的标记中。
<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? 将数据从my_form发送到iframe以便它在iframe中呈现正确内容的正确方法是什么? The iframe is just going to consume that data and store it in a database.
iframe只会使用该数据并将其存储在数据库中。
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 在您的示例中,iframe似乎没有以任何方式与表单连接,因此不确定iframe的相关性如何,但是
The 的
$('#my_form').submit();
will cause a POST action to your webserver, so you need 将对您的网络服务器执行POST操作,因此您需要
app.post('/age_page', ....);
to receive the post form action in your backend 接收后端的表单操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.