Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:22:36+00:00 2026-05-14T02:22:36+00:00

I am setting the submit function on a form with jQuery then later in

  • 0

I am setting the submit function on a form with jQuery then later in the process I reset the function to something else. What happens is the original function gets called again then the new function when only the new function should have been called.

I am sending the requests with AJAX. The first one validated the values on the server then asks if you want to continue. Clicking the submit again should only call the changed function but for some reason both get called simultaneously with a single click.

What is happening here? Could jQuery be delaying the the setting of the 2nd function on the form submit?

Edit: These are the methods that change the handler.

_confirmationCB: function(json, status) {
  this._setMessage(json['message']);

  if(json['valid']) {
    $('form#form').unbind('submit', this._confirmationRequest);
    $('form#form').submit(this._deleteRequest.bindObject(this));
  }
},

_deleteCB: function(json, status) {
  this._setMessage(json["message"]);

  if(json['valid']) {
    this._setMessage(json["message"]);
    $('td input[type=checkbox]').each(function() {
      if(this.checked) {
        $(this).parent().parent().remove();
      }
    });
  }

  $('form#form').unbind('submit', this._deleteRequest);
  $('form#form').submit(this._confirmationRequest.bindObject(this));
  this._setMessage(true);
},

I am not showing all the code here as the class is somewhat long.

Edit: I just tried unbinding the handler, but it had no effect on the issue I am having.

This is the bindObject function:

Function.prototype.bindObject = function(object) {
  var method = this;
  return function () {
    method.apply(object, arguments);
  };
}

This is not really relevant to the issue I’m having, but somebody asked for it. It is used to bind the class ‘this’ object to methods when called by jQuery $.ajax.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:22:36+00:00Added an answer on May 14, 2026 at 2:22 am

    Have you unbound the previous handler before binding the new one? Can you share some code?

    Edit: Actually your bindObject function has a lot to do with this. The bindObject function returns an anonymous function handler but what you are unbinding is a concrete handler viz. a function name like _deleteRequest etc. This won’t work. Binding and unbinding only work if the same handler is being bounded and removed. So you should probably save the return from bindObject in some var & then use that var to call bind & unbind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three forms and using this jquery function $('form').submit(function() { $.ajax({ type: $(this).attr('method'),
I'm using the funcion clearForms to reset my form after submit: <script> function clearForms()
I have a form, and I have some jquery code to override the submit
I'm using this jQuery Validation script to submit my form(s), but I need some
I have a function called taskButtonClick() that: Sets the variable form to a clone.
How to clear, remove, or reset HTML5 form validation state after setCustomValidity(...); ? Setting
The full story is I want to disable the submit button on a form's
I have a JQuery modal popup form on a classic ASP page. It's set
Is it safe to - within a submit event handler for one form -
I have this snippet of code to Submit a form once, to prevent multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.