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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:20:31+00:00 2026-06-08T13:20:31+00:00

My javascript code – function updateWhatIfPrivacyLevelRemove(recordId, correspondingDetailIDs) { var ajaxCall = $.ajax({ data: {

  • 0

My javascript code –

function updateWhatIfPrivacyLevelRemove(recordId, correspondingDetailIDs) {
    var ajaxCall = $.ajax({ data: { Svc: cntnrRoot,
        Cmd: 'updateWhatIfPrivacyLevel',
        updatePrivacyAction: 'Remove',
        recordID: recordID
        },
        dataType: "text",
        context: this,
        cache: false
    });

    $.when(ajaxCall).then(updateWhatIfPrivacyLevelRemoveSuccess(recordID, correspondingResidentDetailIDs));
}

function updateWhatIfPrivacyLevelRemoveSuccess(recordID, correspondingResidentDetailIDs) {
    //several other lines of non-related code
            $.ajax({ data: { Svc: cntnrRoot,
                Cmd: 'handleResidentRow',
                recordID: 1,
                active: 0
            },
                dataType: "text",
                context: this,
                cache: false
            });
}

within my C# code I handle the call backs for ‘updateWhatIfPrivacyLevel’ and ‘handleResidentRow’. I can tell that the AJAX callback to handleResidnetRow is called before updateWhatIfPrivacyLevel.

Why?

  • 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-08T13:20:33+00:00Added an answer on June 8, 2026 at 1:20 pm

    When you’re trying to set up the callback, you’re actually calling the function. In other words, you’re not passing that “updateWhatIf…” function as the callback, you’re passing in its return value (which looks like it’d always be undefined).

    Try this instead:

    $.when(ajaxCall).then(function() {
      updateWhatIfPrivacyLevelRemoveSuccess(recordID, correspondingResidentDetailIDs);
    });
    

    A reference to a function name is a reference to the function as object, and can be used to pass the function as a callback. However, a reference to a function followed by ( ) is a call to the function, which will be evaluated so that the return value can be used in the context of the surrounding expression. Thus, in your code, you pass undefined (the result of the function call) to the .then() method, which of course won’t do what you want.

    It’s important to keep in mind that jQuery is just JavaScript, and in particular a JavaScript function library. Though the .then() thing looks like a language construct, it isn’t — the JavaScript interpreter doesn’t treat it specially in any way.

    An alternative to using an anonymous function as in my suggestion is to use the .bind() method on the Function prototype in newer browsers. That basically does the same thing for you, but it’s stylistically more like traditional functional programming.

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

Sidebar

Related Questions

javascript code: function getCheckbox(name,id){ var check = 0; var deger = option-checkbox-+id; var dom
Javascript Code YAHOO.util.Event.onDOMReady(function (ev) { var carousel = new YAHOO.widget.Carousel(container, {isCircular: true, numVisible:1}); console.log(carousel.set('navigation',
My JavaScript code is as follows: $(document).keydown(function(event){ var move, inter; clearInterval(inter); inter = setInterval(move
javascript code: $.getJSON(comprueba_login.php, {usuario:$(#usuario).val(), pwd:$(#contrasena).val()}, function(data){ alert(resultado: + data.resultado); }); php code: <?php include
Here's my JavaScript code on my test page. $('#link_share_input').keyup(function () { var link_share_input =
Javascript Code var d = function c() { console.log(c); }; d(); // function c()
I have the following Javascript code: var idJS; $('.disp').click(function () { idJS = $(this).attr(id);
The javascript code is like below. var ADDRESS = { checkit : function(element){ if(event.target.className
I have the following JavaScript code: var cILo=true; var img1=images/title-2a.png; var img2=images/title-2b.png; function loadblinker()
Javascript Code: function jsfunction () { var sayi = 9999; alert('<%= cfunction('+sayi+')%>'); } C#

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.