dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Duplicate Form submission

Hybrid View

  1. #1
    Join Date
    Jun 2013
    Posts
    1

    Duplicate Form submission

    Hi,

    In the below code snippet, frmMain is the name of my form. For some reason this form is submitted twice at random times. There is no way that the user could click the button twice. But still duplicate submission happens occasionally. Unable to reproduce the bug during testing and could not figure out why this is happening. Does anyone get a hint of why this could be happening?

    $('frmMain').addEvent('click', function(e)
    {
    /**
    * Prevent the submit event
    */
    new Event(e).stop();

    /**
    * This empties the log and shows the spinning indicator
    */
    var log = $('log_res').empty().addClass('ajax-loading');

    /**
    * send takes care of encoding and returns the Ajax instance.
    * onComplete removes the spinner from the log.
    */
    this.send(
    {
    update: log,
    onComplete: function(responseText)
    {
    log.removeClass('ajax-loading');
    recordId = "";

    var result = responseText;
    if(result.indexOf("Approved") >=0)
    {
    document.getElementById("log_res").innerHTML ="<b style = 'color:blue'>Leave has been approved successfully</b>";
    document.getElementById("pStatus2").innerHTML ="<b style = 'color:blue'>Leave has been approved successfully</b>";
    }

    if (result.indexOf("Rejected") >= 0)
    {
    document.getElementById("log_res").innerHTML ="<b style = 'color:red'>Leave has been Rejected successfully</b>";
    document.getElementById("pStatus2").innerHTML ="<b style = 'color:red'>Leave has been Rejected successfully</b>";
    }
    setTimeout ("location.reload(true);",3000);

    //Remove the click event
    $('frmMain').removeEvents('click');

    }
    });
    });

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    is it jQuery or what?

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    sorry i didn't notice the thread prefix, it's moo tools. i don't know this library

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles