Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I used below code to submit two forms' data in my website.</p> <p>The idea is that you get the <em>multiple forms data</em> using <code>serialize</code> and combine that data and equalize that to <code>data</code> parameter of the <code>$.ajax</code> function.</p> <p>.</p> <pre><code>// submits two forms simultaneously function submit_forms(form1_id, form2_id) { var frm1_name = $("#" + form1_id).attr('name'); var frm2_name = $("#" + form2_id).attr('name'); if (frm1_name == frm2_name) { alert('The two forms can not have the same name !!'); } else { var frm1_data = $("#" + form1_id).serialize(); var frm2_data = $("#" + form2_id).serialize(); if (frm1_data &amp;&amp; frm2_data) { $("#div_busy").html('&lt;strong&gt;Processing...&lt;/strong&gt;&lt;br /&gt;&lt;img id="busy" src="./images/progress_bar.gif" border="0" style="display:none;" /&gt;'); $("#busy").fadeIn('slow'); $.ajax( { type: "POST", url: "process_sticker_request.php", data: frm1_data + "&amp;" + frm2_data, cache: false, error: function() { $("#busy").hide('slow'); $("#div_busy").css({'color':'#ff0000', 'font-weight':'bold'}); $("#div_busy").html('Request Error!!'); }, success: function(response) { $("#div_busy").hide('slow'); $("#hdnFormsData").html(response); // open popup now with retrieved data window.open('', 'popup2', 'toolbars = 1, resizable=1, scrollbars=1, menubar=1'); document.getElementById("prt").action = 'win_sticker.php'; document.getElementById("prt").target = 'popup2'; document.getElementById("prt").submit(); // reset the action of the form document.getElementById("prt").action = 'list_preview.php'; } }); } else { alert('Could not submit the forms !!'); } } } </code></pre>
 

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