W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2014

Re: [whatwg] HTTP status code from JavaScript

From: Tobie Langel <tobie.langel@gmail.com>
Date: Sun, 25 May 2014 09:58:05 +0200
Message-ID: <2663197103661310640@unknownmsgid>
To: Michael Heuberger <michael.heuberger@binarykitchen.com>
Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>
Hi again,

On May 25, 2014, at 9:35, Michael Heuberger
<michael.heuberger@binarykitchen.com> wrote:

> * It is a redundancy. The browser already knows the status code, just
> not JavaScript.

That argument can equally well be used the other way round: it's a
redundancy to expose in JS something that be easily exposed by the
server.

> * Adding inline JS <script> slows down the page load.

In that case, use a meta tag:

<meta name=http-status content=404>

Then in JS:

var status = parseInt(document.querySelector("meta[name=http-status]").getAttribute("content"));

Should this pattern become pervasive, it might bathe sense to
standardize it and expose it in JS. Frankly, though, it's the first
time I hear of such a request.

--tobie
Received on Sunday, 25 May 2014 07:58:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:28 UTC