jquery - Code runs multiple times in IE/Opera -


i have problem on page code executing multiple times in ie , opera, though works in ff, chrome , safari. using latest jquery, validation plugin , form plugin. code originates following html:

<form action="/case_study/php/survey_submit.php" id="mt_survey" method="post"> ... ...              <fieldset id="submit_button_box">     <input id="submit_button" type="submit" value="submit case data" /> </fieldset></form> 

when click submit button should run following jquery:

  $('#mt_survey').submit(function() {     if ( ($("#mt_survey").valid() == true) || confirm("unfinished form, continue saving temporary?")) {       $('#mt_survey').ajaxsubmit({          data: {table: "mt_data"},          target: '#messages',          success: function() {             $('#messages').fadein('slow');            $( 'html, body' ).animate( { scrolltop: 0 }, 0  );}           });         }     return false;    }); 

now works when click submit button first time. @ point form cleared next set of data. done following code.

  $('#clear_form').click(function() {     $("#mt_survey").resetform();     $("#messages").replacewith('<div id="messages"></div>');     $("#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', '');   }); 

now once done, form get's filled out again, , submit clicked again. time in ie , opera code gets run multiple times. know sure it's runing multiple times since checked putting alerts in there, calling "survey_submit.php" file multiple times , inserting data mysql. ideas why? it's been plaguing me long time , see no reason why it's doing so.

do need use form plugin? same effect using

$('#mt_survey').submit(function() {    var $this = $(this);    if ( ($this.valid() == true) || confirm("unfinished form, continue saving temporary?")) {      $.ajax({         data: $this.serialize + "&table=mt_data",         success: function(response) {            $('#messages').html(response).fadein('slow'); //you may need processing of response data before injecting html           $( 'html, body' ).animate( { scrolltop: 0 }, 0  );}          });        }    return false;   }); 

and debugging easier


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -