This project is archived and is in readonly mode.

#579 ✓wontfix

Enhance Request to use onerror

Reported by Bluebie | January 28th, 2009 @ 12:10 AM | in 1.3.0 rc2 (closed)

Currently when making a Request, the failure event only fires if the server responds with some kind of error status code. In Safari, Firefox, and likely Opera (haven't checked), the xhr object has an 'onerror' property. When set to a function, the function fires when there is a network error or any such problem along those lines immidiately after running request.send(), or as soon as the network or server fails if it's a long lived request (comet stuff).

For webapps making use of things like long-polling, it can be important for the application to know when it's requests are getting errors so the user can be informed. In these situations, a timeout isn't a suitable work around.

I propose for this reason that we add this line of code in to the initialize function within request:

this.xhr.onerror = (function() { this.failure(); }).bind(this);

It makes the failure event more meaningful in browsers that support it. We need to find out if such code causes IE any grief. It might complain about trying to add a custom property to the XHR object. We also should find out if IE has any similar proprietary API's we could exploit for similar effect.

Comments and changes to this ticket

  • Bluebie

    Bluebie January 28th, 2009 @ 12:29 AM

    Firefox seems to already do something, I have no idea what exactly, to cause failure to fire. I think it's creating phoney 500 responses or something! Anyway, if we do this we'll probably need to disable it in firefox to stop failure from firing twice.

  • Valerio

    Valerio February 18th, 2009 @ 03:48 AM

    • State changed from “new” to “open”
  • Xandros

    Xandros February 25th, 2009 @ 06:42 PM

    I also added exception handling at this point in my mootools file, dunno which version is better though ...

    // in Request.send() try {, url, this.options.async); } catch(e) { this.fireEvent('exception', 'AJAX request initialization failed\n' + e.message); return; }

  • Christoph Pojer

    Christoph Pojer September 4th, 2010 @ 11:35 AM

    • Milestone changed from 2.0 to 1.3.0 rc2
    • Assigned user changed from “Valerio” to “w00fz”
    • Milestone order changed from “0” to “0”
  • w00fz

    w00fz September 4th, 2010 @ 04:03 PM

    • State changed from “open” to “wontfix”

    We had a discussion and decided to not implement it.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins