My ajax page displays information from a database. It basically goes to the database every second by running a php script that return xml. Javascript parses the xml and puts it into div tags. My page works perfectly for a while, but if I leave the page up for a few hours it will stop working and new data will not display? What could be causing this?? Thanks!
If it works for five minutes, there's no reason it will stop after say 2 hours.. Maybe your DB crashes, your web server crashes or something similar is happening, which is not affected by the script. You can start by checking this things.
er, if it does go and do an ajax call every 1 second, how do you chain this? setTimeout(functionName, 1000) with a self-referencing call within functionName? consider this: usually, your ajax script, if done well and via GET and not POST, will have a reply within 150-200ms tops - use firebug to look at it and confirm your average response times. however, this does not matter - all it takes is for 1 of these to timeout a little - say, due to network lag, cpu strain or whatever - and for the response time to go over 1000ms, running into the next cycle... i think your fix ought to be something along the lines of: create onSuccess event on the ajax handler and do the recursive call to self within it. you can also add some timers that calculate before and after time on the XHR and then determine the difference beween 1000ms and that, using it for the setTimeout within the onSuccess. I hope this makes sense... Also - make sure you dysable async. good luck