Target an iframe with a HTML Post with jQuery

ajax, iframe, javascript, jquery

Solution

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>

You can then use jQuery to submit the form:

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

Problem

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] ) ``` 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. Any ideas?

Original source