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 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
  • 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. 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

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Some other options could be: As the VWSTYLES.XML is just… May 11, 2026 at 9:59 am
  • added an answer Well, a bit more digging tells me that there's no… May 11, 2026 at 9:58 am
  • added an answer Generate a Relative Path It's in Java, but easily translatable… May 11, 2026 at 9:58 am

Related Questions

For some reason every 3-5 days our web app loses the ability to open
I have inherited a client site which crashes every 3 or 4 days. It
I have a J2EE project in Eclipse 3.2 and at the end of every
In ASP.NET 3.5 (with IIS6), are AppDomains are created for every request? I know
Every time I turn on my company-owned development machine, I have to kill 10+
Every time I create a new project I copy the last project's ant file
Every project invariably needs some type of reporting functionality. From a foreach loop in
Every method I write to encode a string in Java using 3DES can't be
Every few days VS2008 decides to get mad at me and fails to generate
Every time I create an object that has a collection property I go back

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.