#49 ✓ duplicate
Radek Pech

AJAX::OnSuccess network failure and status 0

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

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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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

Referenced by

Pages