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 83k
  • Answers 83k
  • 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
  • Editorial Team
    Editorial Team added an answer Consider using NSData to get the string value, and perhaps… May 11, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer Varchar(MAX) is a CLOB (Character Large Object) data type. Here's… May 11, 2026 at 4:45 pm
  • Editorial Team
    Editorial Team added an answer This answer assumes that you have a unique identifier for… May 11, 2026 at 4:45 pm

Related Questions

I have a Rails application that unfortunately after a request to a controller, has
I want to cache custom data in an ASP.NET application. I am putting lots
I've used JQuery to make the elements in a table draggable. (I've never used
I have three applications that talk to each other using sockets. They can all

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.