W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: [XHR] remove "user cancels request"

From: Julian Aubourg <j@ubourg.net>
Date: Tue, 26 Feb 2013 13:30:52 +0100
Message-ID: <CANUEoeu93BMeUJLwHLRzKBse+0=EHwXTHn9XaXQ9JPiNiy82+g@mail.gmail.com>
To: Viktor <vic99999@yandex.ru>
Cc: public-webapps@w3.org
> can i ask, how do you use the "abort" event handler?
> and "error" event handler"
>

In jQuery 1.x, we don't even use onsuccess, onerror and onabort. Reason
being onreadystatechange is the only cross-browser means to handle
XMLHttpRequest when you have to support old IEs (and we try and avoid
having multiple code paths in jQuery because of size, maintainability and
behavioural consistency).

In jQuery 2.x, we use onload and onerror, not onabort. We have some
short-circuit logic in $.ajax to notify author's initiated aborts as errors
with a "cancelled" status but we ignore all other sources of aborts. The
idea is to ignore onunload aborts so that jQuery devs don't have to special
case for it in their error handlers.

Now, to get back to the subject at hand, like Glenn said, it's probably
better to notify those not-author-initiated aborts as errors, because from
the author's POW they're hardly aborts. However, if we do so, we have to
make sure it's possible to differentiate them from a network error. jQuery,
as an author, can then choose to ignore them or bubble them up in $.ajax,
not sure what's best for us at this point but that's another story entirely.
Received on Tuesday, 26 February 2013 12:31:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:57 GMT