S
S
special2010-09-10 10:38:54
JavaScript
special, 2010-09-10 10:38:54

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

4 answer(s)
R
Roman Gogolev, 2010-09-10
@romka777

On the server side, you know the status. Pass it to javascript.
In PHP:
echo '<script type="text/javascript">var status='.$status.';</script>';

H
hamMElion, 2010-09-10
@hamMElion

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?

M
MastaEx, 2010-09-10
@MastaEx

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 :-)

S
Sererator, 2010-09-10
@Serator

httpRequest.status - https://developer.mozilla.org/en/AJAX/Getting_Started .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question