Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I submit a form in a parent window using jQuery without refreshing the contents of the parent window (Ajax submission)
    primarykey
    data
    text
    <p>I am attempting to submit a form contained in a parent window from a child iframe using jQuery without much luck.</p> <p>In the child window I have the following validation function:</p> <pre><code>&lt;script type="text/javascript" src="templates/js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="templates/js/jquery.validate.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $("#form_invoice_item").validate({ submitHandler: function (form) { // Check if main invoice already saved if ($('#invoice_id').val() == "") { // Change target to processing iframe try { parent.$('#invoice_form').ajaxSubmit(); } catch(e) { //debug alert ("Error:" + e); } } else { alert ("Saving invoice " + $('#invoice_id').val() + ' items'); } //form.submit(); //debug } }); }); &lt;/script&gt; &lt;form method="post" id="form_invoice_item" name="form_invoice_item" action="index.php" target="invoice_items"&gt; </code></pre> <p>The error that occurs at <code>parent.$('#invoice_form').ajaxSubmit();</code> is </p> <blockquote> <p>Error:TypeError: Object [object Object] has no method 'ajaxSubmit'</p> </blockquote> <p>If I use the following snippet which is just in plain Javascript, there is no problem(Obviously this isn't jQuery but it gets the job done). How do i do this in jQuery:</p> <pre><code>parent.document.getElementById('invoice_form').target='process'; parent.document.getElementById('invoice_form').submit(); parent.document.getElementById('invoice_form').target=''; </code></pre> <p>I have a hidden iframe called process which has its display property set to hidden. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload