I was wondering whenever this code suppose to work at all. Let say the whole idea to implement something similar to this in Javascript is doubtful. First of all, because you don't have any synchronization techniques in JavaScript at all, but in you code your are relying on particular order of execution of your code, which is not the case in 99%.
By setting: setTimeout( "getStatus", 6000) you create a kind of concurrency, therefore you can get the second script executed first, although you delayed it, but two requests can reach the server at the same time, so probably the second script will not return you anything, so the success function will not executed anymore My hot advise to you consider redesign of your application, since the problem is definetely not in Javascript part at all BTW, I think the use of $. Ajax call has to be as: $. Ajax({ type: "POST", url: "fileReader.
Php", data: { param1: value1, param2:value2...etc}, success: function(respomse){ ...}}) PS. The fact that response take a lot of time to return point to the problem on server side and not in your code in Javascript. And if we started to talk about logging and you've mentioned firebug, you can use console.
Log( "msg") to log into firebug console your messages.
I was wondering whenever this code suppose to work at all. Let say the whole idea to implement something similar to this in Javascript is doubtful. First of all, because you don't have any synchronization techniques in JavaScript at all, but in you code your are relying on particular order of execution of your code, which is not the case in 99%.
By setting: setTimeout( "getStatus", 6000); you create a kind of concurrency, therefore you can get the second script executed first, although you delayed it, but two requests can reach the server at the same time, so probably the second script will not return you anything, so the success function will not executed anymore. My hot advise to you consider redesign of your application, since the problem is definetely not in Javascript part at all. BTW, I think the use of $.
Ajax call has to be as: $. Ajax({ type: "POST", url: "fileReader. Php", data: { param1: value1, param2:value2...etc}, success: function(respomse){ ...}}); PS.
The fact that response take a lot of time to return point to the problem on server side and not in your code in Javascript. And if we started to talk about logging and you've mentioned firebug, you can use console. Log( "msg") to log into firebug console your messages.
You are right about it not being the JS part. It turned out to be the PHP problem which wasn't coming back with anything for a long time because another AJAX method was being made which I think held it up! I need to redesign it!
– Abs Jun 10 '09 at 11:43.
I'm not sure if you can do setTimeout("getStatus();",3000); but I know that you can do setTimeout(getstatus,3000); I'm not sure what you are running into with the slowness, but I would try putting alerts in: before the ajax, and at the success, print to a log in php (possible start and finish), and alert in the javascript when you set the continueTimeout, possibly even alert when the timeout fires... Like: function getStatus(){ alert('getStatus Started'); $. Ajax({ type: "POST", url: "fileReader. Php", data: 'textFile=' + fileNameTxt, success: function(respomse){ alert('ajax success'); textFileResponse = respomse.
Split(" "); $("#done"). Html("Downloading" + textFileResponse0); if(textFileResponse0=='100.0%'){ $("#loading"). Html("Complete"); return; } alert('starting continuetime'); continueTime = setTimeout(**getStatus**, 3000); } });//ajax }.
1 Or if using firebug or webkit, do console.log() instead of alerts. – rpflo Jun 8 '09 at 18:44 Yes, or even create a textarea with an error id and use that to show: var log = $('#errorlogging'); log. Val(log.val() + "Error message...\n"); – Lathan Jun 8 '09 at 19:00 Using the simple alert version for debugging, just like you did Lathan.
I find that the getstatus function only comes back with one successful try and response of an AJAX request. The continuation of AJAX calls is never reached. So the processing of that PHP script must be super slow!
– Abs Jun 8 '09 at 19:07 I'm not that familiar with php, but is there a way you can print to a server error log? Or get the current time of the server at the start and finish to calculate the time the php takes to run? – Lathan Jun 8 '09 at 20:50.
You should better use setInterval instead of setTimeout also don't forget "var" when you are using a new variable. If the passed params are correct and the ajax request still does not return anything then the culprit is server-side.
If you are going for "every 3 seconds" like you say, you want setInterval, not setTimeout, setTimeout just fires once after a delay. – rpflo Jun 8 '09 at 18:46 actually he doesn't want to run those function all the time, that the reason he use setTimeout. You can see, he calls them in the "ping-pong" way, each one calling another under certain condition.
– Artem Barger Jun 8 '09 at 18:50.
Is fileReader. Php calling itself in an infinite loop? Sure sounds like it.By lookng at the little code snippet there, it sure looks like it too.
(Is that the entire code? ) If fileReader. Php is, then it's probably making as many calls as the web server allows per client, and then it's put on hold, which explains why you're not getting a stack overflow error.
When the ajax times out (after 60 secs or whatever) the entire fileReader. Php call stack just dies out, and you're left with the answer from the first ajax. Or maybe you're left with the answer from the first fileReader-call.
Erh not sure. Maybe try adding if(!isset($_POST'textFile')){echo "ERR: POST'textfile' not set!"; exit(-1);} before the part in the fileReader. Php-file you showed.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.