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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:44:06+00:00 2026-05-22T23:44:06+00:00

I am looking for a way to have a .getJSON, call another function which

  • 0

I am looking for a way to have a .getJSON, call another function which in return conducts another .getJSON call.

I’m iteratively calling a JSON method on my Controller and want to finish this iterative cycle if a certain condition is met. If this condition is met (can only be checked from within the JSON method), I want to call another JSON method on the Controller (persisting some data etc.).

However, the second JSON call is never made. When I’m callin the second function manually outside of the first function, the call is made correctly.

Any hints on that or is my design utterly flawed anyways?

EDIT

Chyeaah.. forgot the code.. 😀

 <script type="text/javascript">
    $(window).load(function() {
        var poller = setInterval(tick, 1000);
    });
    function tick() {
        $.getJSON("votingtick", function(voting) {
            if (voting != null) {
                if (voting.timeleft < 0) {
                    clearInterval(poller);
                    finalize();
                } else {
                    $("#timeout").text(voting.timeleft);
                    $("#voters").text(voting.votingCount);
                }
            }
        });
    }
    function finalize() {
        $.getJSON("votingend", function(voting) {
            if (voting != null) {
                $("#finished").fadeIn('fast');
            }
        });
    }
</script>

Think this is most relevant, no?

  • 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-22T23:44:07+00:00Added an answer on May 22, 2026 at 11:44 pm

    I suspect that you have a scope problem with your poller variable. It is probably only defined in your $(window).load function and nowhere else. So when the browser attempts to execute the clearInterval, an exception is thrown and the script is aborted. You can verify this by surrounding the code in your $.getJSON function with a try catch.

    If you remove the var keyword in that function, poller will become a global variable that you can reference anywhere in the script.

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

Sidebar

Related Questions

I'm looking for a way to have a function such as: myFunction({Key, value}, {Key2,
I have a function calling another function to get data. That data might be
I'm looking for a way to have Enum a => UArray a (which makes
I'm looking for a way to have a javascript/jquery function that references dynamically created
I am looking for a way to have some control over the shape of
I'm looking for a way to have an interactive JIT debugger, preferably integrated with
I am looking for a way to not have a plugin execute on install.
I'm looking for a simple way to have this done. I would to have
I am looking for good ideas for implementing a generic way to have a
I am looking for a way to edit data and have values dynamically calculated

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.