Target an iframe with a HTML Post with jQuery

前端 未结 7 2268
遥遥无期
遥遥无期 2020-12-08 07:50

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], 
    [c         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 08:15

    You can solve the no-form-allowed-within-a-form problem by dynamically creating the form and appending it to the body. So you'd do something like this:

    $().ready(function() {
        $('body').append('
    '); });

    That creates your iframe-updating form outside of the main form that encompasses everything else on the page. Then just call it as Josh recommended: $('#myspecialform').submit();.

提交回复
热议问题