使用 jQuery 使用 HTML Post 定位 iframe [英] Target an iframe with a HTML Post with jQuery

查看:20
本文介绍了使用 jQuery 使用 HTML Post 定位 iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 jQuery 或 JavaScript 来发帖,我怎样才能让它针对 iframe 而不是当前页面?

If I'm using jQuery or JavaScript to do a post, how can I make it target an iframe rather than the current page?

jQuery.post( 
    url, 
    [data], 
    [callback], 
    [type] 
) 

这是 jQuery 帖子的格式,似乎没有任何地方可以像 <form> 标签中那样指定目标.

That is the format of the jQuery post, it doesn't seem as though there is anywhere to specify the target like there is in the <form> tag.

有什么想法吗?

推荐答案

您可以通过常规表单执行此操作:

You can do this via a regular form:

<form action="targetpage.php" method="post" target="iframename" id="formid">
   <input type="hidden" name="foo" value="bar" />
</form>

然后就可以使用jQuery提交表单了:

You can then use jQuery to submit the form:

$("#formid").submit();

这篇关于使用 jQuery 使用 HTML Post 定位 iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆