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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:36:41+00:00 2026-05-11T08:36:41+00:00

Every 3 seconds I make an AJAX POST request to get the status of

  • 0

Every 3 seconds I make an AJAX POST request to get the status of a process. This works great.

When the process reaches 100% a call back function executes(indicated below) to add new elements to the page and then it cancels the setTimeout method that use to continuously get the progress every 3 seconds. However, I have been told by my users it sometimes fails to cancel and the new elements are not added to the page and I’ve been that it get stuck at showing ‘100%’.

I have tested this again and again and it never gets stuck for me. The code also looks ok, but my JavaScript skills are not great so I was hoping someone could point out if there is potential of this problem happening?

I have commented the code, apologies its very long. I have tried to reduce it.

function convertNow(validURL){      startTime = setTimeout('getStatus();', 6000);         //AJAX CALL TO RUN PROCESS        $.ajax({        type: 'GET',        url: 'main.php',        data: 'url=' + validURL + '&filename=' + fileNameTxt,        success: function(msg){        //ON SUCCESS CLEAR SETTIMEOUT AND SHOW ELEMENTS (text)        clearTimeout(continueTime);        clearTimeout(startTime);             $('#loading').hide('slow');         $('#done').html('Done');           }//function       });//ajax  }//function convertNow  function getStatus(){         //AJAX CALL TO GET STATUS OF PROCESS         $.ajax({         type: 'POST',         url: 'fileReader.php',         data: 'textFile=' + fileNameTxt,         success: function(respomse){         textFileResponse = respomse.split(' ');         $('#done').html('Processing...');         }         });//ajax         clearTimeout(continueTime);          if(textFileResponse[0]=='100.0%'){             clearTimeout(continueTime);         }         else{             clearTimeout(startTime);             continueTime = setTimeout('getStatus();', 3000);          } } 
  • 1 1 Answer
  • 2 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. 2026-05-11T08:36:41+00:00Added an answer on May 11, 2026 at 8:36 am

    There’s probably a parsing error in the textFileReponse[0]==’100.0%’ in some edge cases, with the value in the response not equaling exactly 100.0% (maybe there’s extra whitespace, or maybe there are some minor differences on some platforms, etc…). This would cause the code to fall through to the else {} block, and your getStatus function would be queued up again.

    EDIT: Given the thread in the comments, it’s also an equal likelyhood that there’s a race condition going on between the two blocks of Ajax code. (just putting this here for the benefit of readers). END EDIT

    What you probably want, in addition to resolving the parsing, however, is to use setInterval(), with only one timer, instead of a startTime and continueTime timer. setTimeout executes only once, whereas setInterval repeats every x milliseconds, so you’d need only one. To cancel a setInterval, use clearInterval.

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

Sidebar

Related Questions

I need to make an Ajax call for every x seconds, to read the
How do I make this interval from every 2 seconds to randomly X -
I would like to execute an Ajax request every seconds. My next code work
I'm running an AJAX request from a JavaScript-powered (+jQuery) webpage every 5 seconds for
I've an AJAX request which will be made every 5 seconds. But the problem
I'm using jQuery. This is my second post to make my old question more
I make an AJAX call to a PHP script like so: function convertNow(validURL){ $.ajax({
What I have is a treegrid populated with values from ajax. Every 30 seconds
I'm trying to make a real time graph that updates every X seconds and
I'm trying to make a proxy-like page that forwards an AJAX request to a

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.