Answer the question
In order to leave comments, you need to log in
Server response status (200, 404, ...) on synchronous page load?
How to use javascript to find out the status of the server response (200, 404, ...) during the initial synchronous page load? Those. XMLHttpRequest does not exist in this case.
Answer the question
In order to leave comments, you need to log in
On the server side, you know the status. Pass it to javascript.
In PHP:
echo '<script type="text/javascript">var status='.$status.';</script>';
If you received a response from the server 200, 404, ... during the initial synchronous download, then the javascript code could not get into the client browser and cannot be executed.
If it is still necessary, pay attention to the scripts embedded in the browser, but where is the guarantee that all your visitors will install this plugin?
You can request the same page again via XMLHttpRequest.
In general, some strange task, I would like to answer that you should not need it :-)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question