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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:21:07+00:00 2026-06-09T15:21:07+00:00

I am executing async AJAX requests which are being wrapped into function. Where $.ajax

  • 0

I am executing async AJAX requests which are being wrapped into function. Where $.ajax is Deferred object and I can use .promise properly (check: Initially Loaded) then I won’t be able to do the same with ‘Now really loaded’ which will be executed before ajax finish loading.

function WSCall(method, data, callback, type, async, bg) {
    // .. code ..
    var promise = $.ajax({
        'url': useSampleData ? useSampleData || null,
        //'async': false,
        'type': 'POST',
        'dataType': (type == null) ? 'json' : type,
        'data': data,
        'beforeSend': bg ? null : LoadingBegin,
        'complete': bg ? null : LoadingEnd,
        'success': callback,
        'error' : bg ? null : function(jqXHR, textStatus, errorThrown) { networkError = 1; }
    });

    promise.done(function(){ console.log('Initially loaded') });
}

function aSyncEvent() { 
    WSCall(
        'status',
        {},
        function (data) {
            if (data.error) { 
                console.log('Error occured'); return ShowDialogAlert(data.error); }
            if (data.statusResult) {
                var parts = data.statusResult.split('-');
                if (parts[1] === '0') { 
                    sId = parts[0]; 
                    console.log('Wow its loaded!'); 
                    return true; 
                }               
            }
        }
    )   
}

$.when( aSyncEvent() ).then( function () { console.log('now really loaded')});

Initially loaded and Wow its loaded will appear properly AFTER ajax has been executed in proper order however ‘now really loaded’ will appear before ajax finishes executing.

I beg for help regarding this matter.

Thanks
Mike

  • 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-09T15:21:09+00:00Added an answer on June 9, 2026 at 3:21 pm

    Have you tried returning your deferred?

    function WSCall(method, data, callback, type, async, bg) {
        // .. code ..
        return promise.done(function(){ console.log('Initially loaded') });
    }
    

    and

    function aSyncEvent() { 
        return WSCall(
            // .. code ..
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: When executing around 10 jQuery $.ajax requests at once, I can see all
When I log in into my app, an async task starts executing and while
Setup: I am doing an ajax-jsonp call, which is working fine. The callback function
I have a javascript function which asks for some ajax data and gets back
Executing the following sql: USE [WSS_Content] EXEC sp_helplogins returns two result sets, and within
I executing a function like this, <script type=text/javascript> $(document).ready(function() { getEntities(Clients/GetClients, 0, formatClientsResult); var
I am working with JQuery dialog which is opened before an ajax call and
I've been thinking about std::async and how one should use it in future compiler
I've a async method in my singleton session bean, which after a few minutes
I'm using blocks to handle the response of async http requests in a non-ARC

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.