#49 bug
Radek Pech

AJAX::OnSuccess network failure and status 0

Reported by Radek Pech | April 25th, 2008 @ 10:45 AM | in 1.6.1

The description of OnSuccess (Ajax.Request) says that this event is rised only for the server response 2YZ (i.e. 200, 201, etc.).

But when the request times out (e.g. server is down), it returns readyState == 4 and status == 0 and the OnSuccess is called.

To solve the timeouts, you have to use this code:

new Ajax.Request('/some_url',

{

onFailure: function(transport) {

alert('Error: '+transport.status);

}

onSuccess: function(transport) {

if (transport.status == 0) {

alert('Timeout error');

} else {

alert('Response: '+transport.responseText);

}

}

);

This collides with the advantage gain from using OnSuccess/OnFailure instead of onComplete with status testing.

Tested on FF 2.0.0.14

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

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

The Prototype JavaScript library.

Shared Ticket Bins