Note that there are some explanatory texts on larger screens.

plurals
  1. POCode runs multiple times in IE/Opera
    text
    copied!<p>I have a problem on my page with code executing multiple times in IE and Opera, though it works in FF, Chrome and Safari. I am using the latest jQuery, the validation plugin and the form plugin. My code originates from the following html:</p> <pre><code>&lt;form action="/case_study/php/survey_submit.php" id="mt_survey" method="post"&gt; ... ... &lt;fieldset id="submit_button_box"&gt; &lt;input id="submit_button" type="submit" value="Submit Case Data" /&gt; &lt;/fieldset&gt;&lt;/form&gt; </code></pre> <p>When I click the submit button it should run the following jquery:</p> <pre><code> $('#mt_survey').submit(function() { if ( ($("#mt_survey").valid() == true) || confirm("Unfinished form, continue saving as temporary?")) { $('#mt_survey').ajaxSubmit({ data: {table: "mt_data"}, target: '#messages', success: function() { $('#messages').fadeIn('slow'); $( 'html, body' ).animate( { scrollTop: 0 }, 0 );} }); } return false; }); </code></pre> <p>Now this works when I click the submit button first time. At this point the form is cleared for next set of data. This is done by following code.</p> <pre><code> $('#clear_form').click(function() { $("#mt_survey").resetForm(); $("#messages").replaceWith('&lt;div id="messages"&gt;&lt;/div&gt;'); $("#messages").hide(); $("#escort_div").hide(); $("#transport_a_div").hide(); $("#transport_l_div").hide(); $("#item_div").hide(); $("#item2_div").hide(); $("label.error").hide(); $("#correction_button").attr('disabled', 'disabled'); $("#submit_button").attr('disabled', ''); }); </code></pre> <p>Now once that is done, the form get's filled out again, and submit is clicked again. But this time in IE and Opera the code for it gets run multiple times. I know for sure it's runing multiple times since I checked by putting alerts in there, but mostly it is calling my "survey_submit.php" file multiple times and inserting data into MySQL. Any ideas why? It's been plaguing me for a long time and I see no reason why it's doing so.</p>
 

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