How to check local server or internet server is online/offline using only js/jquery? no angular or nodejs



Hello Everyone
i am working to buld an html template and add php contact form. i code to check whether my local server or (when i upload to internet hosting server ) internet server is online or offline to run my php file.
if server is offline i want to show an error message page and i wants to find this using core javascript or jquery no angular nodejs or anyother framework.
Thanks for reading and help me.


Why? Do you expect it to be offline a lot?


actually i wants when someone or me open this html template and when someone try to send a contact form information i show him a page. i just validate it in simple words. and i need this. Do you have any idea?


But if the server is offline, how can people see the contact page at all?


No, you can't understand. the contact form is show whenever server is on/off i wants if someone submit form if server is offline then show an error message page as php won't run until server is on. This is what i want.


Scallio's question is more along the lines of 'why is your form handler on a different server'.

As for figuring out if the other server is online, fire an AJAX request off to the root of the other server. If the response code comes back 200, the server's online and listening correctly.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.