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 7975669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:42:24+00:00 2026-06-04T08:42:24+00:00

I need to call some functions in sequence on form submit button click –

  • 0
  1. I need to call some functions in sequence on form submit button click –

    func1() -> func2() -> func3() … -> func7() -> …

  2. All these functions do some kind of validation/checking and if validation fails, display a confirmation dialog to the user. If the user confirms, the next function in queue is executed.

  3. Any of these functions could be doing some asynchronous task like sending Ajax request and depending on the result, showing the user some confirm dialog.

Details

I have asynchronous functions with the following structure –

function preValidateUrls(evt)
{
   evt.preventDefault();

   $.ajax({
       type: "POST",
       url: posturl+"?"+params,
       dataType: "json",
       success: function(res)
           { 
                 //display some confirmation dialog
                 if(confirm(msg)) 
                 {
                       $("form#frmBanners").submit();
                 }
            }
        });
}

How do I do this?

To begin with I just had two synchronous functions defined like this –

<form onsubmit="return func3()">
...
...
<input type="submit" onclick="return func1()"/>
</form>
  • func1() was being called at first, displaying confirmation dialog, then func2()…

  • Then I defined asynchronous function func2() (with the same structure as shown above) and called it like this –

    $(“input#formsubmitbutton”).click(func2);

But, as expected, this does not wait for the confirmation of func1().

  • If I do like the following, the function func2 gets called again and again –

    $(‘form#frmBanners’).submit(function()
    {
    return func2(); //This is called after preValidateUrls()
    });

How do I do this in a clean way, so the tomorrow when I need to add any synchronous/asynchronous functions in between, I just need to edit at one place, something like –

func1() -> func2() -> func3() ... -> func7()

P.S. – I know, how to use callback functions in javascript.

  • 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-06-04T08:42:25+00:00Added an answer on June 4, 2026 at 8:42 am

    How about just one function in the submit handler:

    <form action="" onsubmit="return func_test_all();">
    </form>
    

    Then inside your func_test_all() you set up a Deferred pipe and return false; at the end to prevent immediate form submission.

    I have to run, so I don’t have a complete code sample; I hope you can figure out the Deferred 😉 will only be back in 3 hours or so.

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

Sidebar

Related Questions

I need to call source on a snow cluster to re-eval some functions. The
I need to call some functions generated by some libs. I will need to
Need to call a filter function on some options based on a radio selected
I need to call some PL/SQL procedures from my Java application. I can do
I need to call some methods in Wininet.dll from a Java program. I can
I'm kinda lost, i need to call some python code after the creation of
I need to call from my code for some other program . And I
I need to run some methods before the first call of a wcf service,
I need some help on the JavaScript. I do a ajax call on a
I have an helper class with some static functions. All the functions in the

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.