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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:32:14+00:00 2026-06-15T12:32:14+00:00

Having what I thought should be a relatively easy problem to deal with being

  • 0

Having what I thought should be a relatively easy problem to deal with being a major pain… I am trying to do:

a.b("param", function(data)
{
     logger.debug("a.b(" + data.toString() + ")");

     if (data.err == 0)
     {
           // No error, do stuff with data
     }
     else
     {
           // Error :(  Redo the entire thing.
     }
});

My approach to this was to try:

var theWholeThing = function() {return a.b("param", function(data)
{
     logger.debug("a.b(" + data.toString() + ")");

     if (data.err == 0)
     {
           // No error, do stuff with data
     }
     else
     {
           // Error :(  Redo the entire thing.
           theWholeThing();
     }
})};

The problem with the above is while the former did work (except didnt deal when an error occurred), the latter simply never prints the log message… its as if “theWholeThing()” call isn’t working as I thought it should (call the whole thing again).

There must be something subtly wrong here, any tips?

Thanks!

  • 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-15T12:32:15+00:00Added an answer on June 15, 2026 at 12:32 pm

    First, to answer you question directly, it sounds like you forgot to actually call the function the first time. Try:

    var theWholeThing = function() {return a.b("param", function(data)
    {
         logger.debug("a.b(" + data.toString() + ")");
    
         if (data.err == 0)
         {
               // No error, do stuff with data
         }
         else
         {
               // Error :(  Redo the entire thing.
               theWholeThing();
         }
    })};
    
    theWholeThing(); // <--- Get it started.
    

    However, this can be achieved a little more elegantly in a named IIFE (immediately invoked function expression):

    // We wrap it in parentheses to make it a function expression rather than
    // a function declaration.
    (function theWholeThing() {
        a.b("param", function(data)
        {
             logger.debug("a.b(" + data.toString() + ")");
    
             if (data.err == 0)
             {
                   // No error, do stuff with data
             }
             else
             {
                   // Error :(  Redo the entire thing.
                   theWholeThing();
             }
        });
    })(); // <--- Invoke this function immediately.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with what I thought should be a pretty simple problem. I
I am creating a social bookmarking app. I am having a re-thought of the
Having read other people's questions I thought window.onload=... would answer my question. I have
I am having problems finding a solution for what I thought would be straight
I thought this was covered elsewhere but I don't see it now. Anyway, having
I'm having difficulty iterating through records while scrolling window. My initial thought was to
Having trouble with each function... Will try to explain by example... In my code,
I would have thought this should be available from the admin but I cant
I've recently discovered, to my astonishment (having never really thought about it before), machine-sorting
I am having an issue that is stumping me. I have a relatively simple

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.