Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery iframe 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.

like image 526
Lee Avatar asked Aug 04 '10 15:08

Lee


1 Answers

add this AFTER you insert the IFRAME into the DOM:

 $("#externalSite").contents().find('form').submit()
like image 69
Bob Gregor Avatar answered Sep 25 '22 10:09

Bob Gregor