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

  • SEARCH
  • Home
  • 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 6836971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:25:13+00:00 2026-05-26T23:25:13+00:00

I want to attach a submit() handler to a form to run an ajax

  • 0

I want to attach a submit() handler to a form to run an ajax request, and when that comes back, the form submits itself normally. Is this possible? $(‘#myForm’).submit() will just recursively call the same function.

I’d rather not attach the event handler to the click of the submit button, because not all users submit forms with the mouse. Many, like myself, just use the return key.

  • 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-26T23:25:13+00:00Added an answer on May 26, 2026 at 11:25 pm

    Try this. In the below code I am unbinding the form submit event handler in ajax success handler and then submitting the form.

    $('form').bind('submit', function(){
    
        //Do ajax call here
        $.ajax({
           url: "url",
           success: function(){
              //On success do what you want to do 
              //and then ubind the submit event handler and submit the form
    
              $('form').unbind('submit').submit();
           }
        });
    
        //Prevent default form submit
        return false;
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, what I want is basically to attach a javascript handler to a form,
I have a form that I submit through ajax, and returns an updated chunk
I have a form. This form submits via POST to an iframe, that, in
I want to attach an xslt stylesheet to an XML document that I build
I want to attach a 'click' event handler to the first child of an
need a little help with this one. I have a form that I am
I want to attach SQL Server 2005 database at runtime. Can this be achieved
If I want to fetch a form, then grab some button, then attach some
I've made jQuery & AJAX script that uses a PHP function to bring back
Want to attach an Event Handler/Listener to some links using the delegate() method, but

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.