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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:23:29+00:00 2026-05-12T00:23:29+00:00

Maybe there is no difference, but is either way better than the other (or

  • 0

Maybe there is no difference, but is either way better than the other (or perhaps a mysterious ‘third’ way better than both!)…


first:

var startTime;

$(document).ready(function() {

    $("#lbl_ajaxInProgress").ajaxStart(function() {
        // store the current date/time...
        startTime = new Date();
        // update labels
        $(this).text('Yes');
        $("#lbl_ajaxCallTime").text("-");
    });

    $("#lbl_ajaxInProgress").ajaxStop(function() {
        // update labels
        $(this).text('No');
        $("#lbl_ajaxCallTime").text(myFunctionThatCalculatesTime(startTime));
    });

});

second:

var startTime;

$(document).ready(function() {

    $("#lbl_ajaxInProgress").ajaxStart(function() {
        // update labels
        $(this).text('Yes');
    });

    $("#lbl_ajaxInProgress").ajaxStop(function() {
        // update labels
        $(this).text('No');
    });

    $("#lbl_ajaxCallTime").ajaxStart(function() {
        // store the current date/time...
        startTime = new Date();
        // update labels
        $(this).text("-");
    });

    $("#lbl_ajaxCallTime").ajaxStop(function() {
        // update labels
        $(this).text(myFunctionThatCalculatesTime(startTime));
    });

});
  • 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-12T00:23:30+00:00Added an answer on May 12, 2026 at 12:23 am

    An interesting fact is that ajaxStart, etc. are actually just jQuery events. For instance:

    $("#lbl_ajaxInProgress").ajaxStart(function() {
      // update labels
      $(this).text('Yes');
    });
    

    is equivalent to:

    $("#lbl_ajaxInProgress").bind("ajaxStart", function() {
      // update labels
      $(this).text('Yes');
    });
    

    This means that you can also attach namespaces to ajaxStart/ajaxStop, etc. Which also means that you can do:

    $("#lbl_ajaxInProgress").unbind("ajaxStart ajaxStop");
    

    You could also do:

    $("#lbl_ajaxInProgress").bind("ajaxStart.label", function() {
      // update labels
      $(this).text('Yes');
    });
    
    $("#lbl_ajaxInProgress").bind("ajaxStop.label", function() {
      // update labels
      $(this).text('No');
    });
    

    And then:

    $("#lbl_ajaxInProgress").unbind(".label");
    

    Cool, huh?

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

Sidebar

Related Questions

maybe it's dumb but is there a difference between new Something().method(); and Something tmpSomething
Maybe there's no way to solve this the way I'd like it but I
I'm not very good at regex but maybe there's a simple way to achieve
Maybe there is a proper term for this, but what if you want to
I call this a flash meeting, but maybe there is another more appropriate name.
Is there such a thing? Maybe there should be, I don't think Microsoft built
Is there a working JPA 2 implementation for JBoss server? Or maybe there is
Wanted to know if someone had a suggestion on code or maybe there's a
I haven't exactly found the answer to this, maybe there is no best one.
This is my first attempt to use WCF so there may be something fundamentally

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.