townclown Posted September 5, 2008 Share Posted September 5, 2008 Hi, I have an ajax function that calls a php script which loops until data in a database changes and returns xml to the ajax function -> which then calls itself again. Works a charm, but, if you refresh the page while the loop is running it takes AGES to reload. I assume the PHP script is waiting to timeout? I added a button which calls a function to stop the loop(will not get into it but it stops the PHP loop using session variables), after which you can refresh and the page reloads swiftly. Is there anyway i can call that function when the user refreshes the page - my php is 10 times better than my javascript im afraid. Thanks in Advance. Darren Quote Link to comment Share on other sites More sharing options...
barkermn01 Posted September 5, 2008 Share Posted September 5, 2008 <body onUnload="AJAXHandle.abort();" /> This will stop your AJAX Call if the refresh or leave the page so php is terminated Quote Link to comment Share on other sites More sharing options...
townclown Posted September 5, 2008 Author Share Posted September 5, 2008 Unfortunately that doesn't work for me i did try before when creating the function to stop the request. abort() just does not cancel it for some reason. Quote Link to comment Share on other sites More sharing options...
barkermn01 Posted September 5, 2008 Share Posted September 5, 2008 Then it is not an AJAX Problem as abort() stop the connection thus stops the php if you are constanly reloading via AJAX try using a IFrame and add an out refresh to the code it would use so mutch less processing power allso the more javascript you use slower your site becomes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.