I see that Sam added a new function to 1.6
svn--Ajax.Request.getStatus(). I'm curious because I just did some
research on status codes when the network connection is dropped and
wondered if any of you (especially Sam) have any additional insight.

To summarize the situation: when ajax calls encounter network errors,
FF2 throws an exception when reading transport.status; Opera 9 and
Safari 3 show transport.status = 0; IE6 and IE7 show transport.status =
12029 (or one of 5 other values).

I see the new getStatus() function now accounts for exceptions and
transport.status of 0 (O9, S3, FF2), and thus has an "on0" callback.  I
propose adding IE support and changing the callback name to
"onNetworkError".

Here is the code (I will submit a patch):


Ajax.Request = {
...
  success: function() {
    var status = this.getStatus();
    return status != 'NetworkError' && status >= 200 && status < 300;
  },

  getStatus: function() {
    try {
      var status = this.transport.status;
      if ([0, 1223, 12002, 12029, 12030, 12031, 12152].include(status))
        return 'NetworkError';
      return status;
    } catch(e) {
      // allow callback functions to access properties without
generating an Exception
      this.transport = {};
      return 'NetworkError';
    }
  },
...

Network error scenarios:
FF - throws exception
IE6/7 - transport.status = 12029 (or other, see below)
S3 - transport.status = 0
O9 - transport.status = 0

IE status Error codes:
1223 : Client canceled request
12002: Server timeout
12029: Dropped connection
12030: Dropped connection
12031: Dropped connection
12152: Connection closed by server

Also of note is that FF 1.x returns a status of 200 on network errors
(no Exception), so the developer is left to see that the response is
empty to know of a failure.

references:
http://dev.rubyonrails.org/changeset/7265
http://developer.yahoo.com/yui/docs/connection.js.html
http://www.thescripts.com/forum/thread573352.html
http://trac.dojotoolkit.org/ticket/2418


- Ken Snyder


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to