Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery submit function does not work
    primarykey
    data
    text
    <p>I'm developing a webpage which creates a form with various select tags dynamically. Unfortenatley the jquery submit function passes incorrect information to the php file (form_submit.php) that must process this information; the (netbeans 7.4) debugger always shows default (not selected) values in $_POST within the php file instead of the selected values . The even stranger part: when I copy (in the code below) the console output with the serialised formdata straight into the following ajaxcode (see code), the php debugger shows the correct -selected values within the $_POST array..(?)</p> <p>The resulting form is quite substantial. The only theoretical cause I can think of is that therefore the execution of 'var dataAjax = $( this ).serialize();' takes time and is not finished when the following ajax call starts...(??)</p> <p>The code:</p> <pre><code>$("#myForm").submit(function(event){ event.preventDefault(); var dataAjax = $( this ).serialize(); //does not work, but when copying the string from the console in line below it does work. console.log('SUBMITTED FORM: '+ dataAjax ); //next line is only used as a test //var dataAjax = 'agreementapproval0=SolarX_10&amp;selected_emeterproductid0=SolarX_10_1_1&amp;selected_eproductid0=SolarX_10_2_4&amp;selected_emeterproductid1=NOSELECTION&amp;selected_emeterproductid2=NOSELECTION&amp;selected_eproductid1=NOSELECTION&amp;selected_eproductid2=NOSELECTION&amp;form_token=30688e467ee88167805ad0f330809d74'; $.ajax({ type: "POST", url: "form_submit.php", data: dataAjax, dataType: "json", async: true, success: function(msg){ if(msg.statusgeneral == 'success'){ } else { }//else }, //succes: function error: function(){ $("#errorbox").html("There was an error submitting the form. Please try again."); } });//.ajax //make sure the form doesn't post //return false; //depreciated //} //if(form.valid() });//$("#myForm").submit() &lt;form id="myForm" name="myForm" action="" method="post"&gt; &lt;div id="wrapper"&gt;&lt;/div&gt; &lt;!--anchor point for adding set of product form fields --&gt; &lt;input type="hidden" name="form_token" value="&lt;?php echo $form_token; ?&gt;" /&gt; &lt;input type="submit" name="submitForm" value="Confirm"&gt; &lt;/form&gt; </code></pre>
    singulars
    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