jQuery iframe表单提交 [英] jQuery iframe form submit

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

问题描述

有什么办法从jQuery提交一个iframed表单?我有以下内容:

  $('button#bookingButton')。click(function(){
$('< iframe id =externalSiteclass =externalSitesrc =/ form / page/>')。dialog({
title:'Form',
autoOpen:true ,
width:800,
height:600,
modal:false,
resizable:false,
按钮:{$ b $'Close':function ){$(this).dialog(close);},
'Add Booking':function(){$('form#bookingForm')。submit();}
}
})。width(800 - 25);
});

这会创建一个jQuery UI对话框,其中包含一个iframe。这工作正常,常规提交按钮工作正常,但jQuery按钮不提交表单。 解决方案

将IFRAME放入DOM:

  $(#externalSite)。contents()。find('form')。submit ()


Is there any way to submit an iframed form from jQuery? What I have is the following:

$('button#bookingButton').click(function(){
    $('<iframe id="externalSite" class="externalSite" src="/form/page" />').dialog({
        title:'Form', 
        autoOpen: true, 
        width: 800, 
        height: 600, 
        modal: false, 
        resizable: false,
        buttons:{
            'Close':function(){$(this).dialog("close");},
            'Add Booking':function(){$('form#bookingForm').submit();}
        }
    }).width(800 - 25);
});

This creates a jQuery ui dialog which has an iframe within it. This works fine and the regular submit button works fine however the jQuery button does not submit the form.

解决方案

add this AFTER you insert the IFRAME into the DOM:

 $("#externalSite").contents().find('form').submit()

这篇关于jQuery iframe表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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