0

Using jquery / ajax I'm calling a php script which then runs a process which restarts apache2 on the server the pages are being supplied from.

I want the script to loop until a web page on the server is accessible (ie: apache2 has restarted) or x seconds expire.

Currently I use a setTimeout(function(){} with a timeout of 10 seconds. This works but I feel it could be problematic, or the timeout could happen when apache2 hasn't restarted.

Anyone any ideas how I can create a jquery loop checking if a page is accessible or not, or timeout after say 10 seconds ?

Thanks

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
Rocket
  • 1,065
  • 2
  • 21
  • 44
  • 2
    Use `setInterval()` to run a function ever N seconds and test whether the server is availble. When it succeeds, cancel the interval timer. – Barmar Mar 12 '20 at 09:38
  • 1
    Does this answer your question? [Calling a function every 60 seconds](https://stackoverflow.com/questions/3138756/calling-a-function-every-60-seconds) – Heretic Monkey Mar 12 '20 at 12:26

0 Answers0