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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:11:54+00:00 2026-06-07T15:11:54+00:00

I have 2 functions. function f1() { $.ajax(…, success: function(response) { // some code

  • 0

I have 2 functions.

function f1() {
    $.ajax(..., success: function(response) {
        // some code executed whenever request is completed.
    }
}

function f2() {
    // my code
}

I need to call these functions one after another.

f1() // waiting until ajax request in the function is complete.
f2()

I tried $.when().then(), however it didn’t seem to work.

  • 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-07T15:11:57+00:00Added an answer on June 7, 2026 at 3:11 pm

    The $.ajax call returns an instance of $.Deferred which is used to track the progress of the call – that is what you need to return from your f1 function. You can then use .then(), .done() etc.

    Edit in response to comments

    If you want to invoke a callback within f1 as well as externally you can return the result of the .pipe method.

    function f1() {
        return $.ajax(/*...*/).pipe(function() {
            //local 'done' handler
        });
    }
    
    function f2(resultFromF1Handler) {
        //...
    }
    
    f1().done(f2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AJAX call that returns some JSON like this: $(document).ready(function () {
Im using jquery to call a page via ajax. I have some jquery functions
I have jQuery functions; e.g A(), B() and C() Each function makes some Ajax
So, I have two JavaScript functions: function Generate() { //Do something $.ajax({data:{Svc: 'cpMain', Cmd:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have a jQuery ajax function that retrieves JSON data. In the success block
I have a setup where I get some information, in an ajax call, then
I have an ajax function in jquery calling a php file to perform some
I have two functions, one that makes an Ajax request when the user loads
I have a jQuery ajax function. the callback function consists of two functions: 1)

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.