My users keep complaining that a link does not show up for them. For me, I have tested this on several browsers and it works for me.
What should happen is that a process is started via AJAX using JQuery and once that is done I keep checking with the server via AJAX how much of the process has been done and once the process is complete I show them a link. But a lot of users tell me that it shows them the link and it quickly disappears back to showing 100.0%!
I can’t see how I can fix this and I was hoping you guys could help me write something fool proof so that the link is always shown!
Here is the code concerned (its been shortened).
var startTime; var continueTime; var done = false; function convertNow(validURL){ startTime = setTimeout('getStatus();', 6000); $.ajax({ type: 'GET', url: 'main.php', data: 'url=' + validURL + '&filename=' + fileNameTxt, success: function(msg){ done = true; $('#loading').hide('slow'); $('#done').html('LINK SHOWN HERE'); }//function });//ajax }//function convertNow function getStatus() { if(done==false){ $.ajax({ type: 'POST', url: 'fileReader.php', data: 'textFile=' + fileNameTxt, success: function(respomse){ textFileResponse = respomse.split(' '); $('#done').html('PROGRESS SHOWN HERE IN PERCENTAGES'); } });//ajax continueTime = setTimeout('getStatus();', 3000); } }
Thanks all
P.S. I have this question before and was given an idea of using a conditional in the function but that didn’t work when it should have!!
UPDATE
I have some of my users what OS and browsers they are using and they usually say a Mac Os and firefox or safari. Not sure if that help with the solution.
The behaviour described by the users suggests that the
successcallback of yourgetStatusfunction is called after the one inconvertNow. You should testdonevariable in this callbackEDIT : This solution should prevent the bug from appearing most of the time, but there is still a chance. The only way to be sure is to remove the callback from
convertNowand let the one ingetStatusset the link when the processing is done (don’t forget to allow only one call togetStatusat a time, see ‘BONUS’ modification above).