Bug Tracker

Ticket #6748: 0001-Treat-an-xhr.status-of-0-as-successful-only-in-Opera.patch

File 0001-Treat-an-xhr.status-of-0-as-successful-only-in-Opera.patch, 1.3 KB (added by benjamn, 10 years ago)

Patch to make the Opera special case more Opera-specific.

  • src/ajax.js

    From 75d4b59a4c72ab6fde3aa1e815947639213ea9da Mon Sep 17 00:00:00 2001
    From: Ben Newman <ben@quora.com>
    Date: Wed, 30 Jun 2010 22:25:17 +0000
    Subject: [PATCH] Treat an xhr.status of 0 as successful only in Opera, where 0 really means 304.  In Chrome Mac, for example, an xhr.status of 0 means an error occurred.
    
    ---
     src/ajax.js |    7 ++++---
     1 files changed, 4 insertions(+), 3 deletions(-)
    
    diff --git a/src/ajax.js b/src/ajax.js
    index 2c4f13c..42b74cf 100644
    a b jQuery.extend( jQuery.ajax, { 
    627627                try {
    628628                        // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
    629629                        return !xhr.status && location.protocol === "file:" ||
    630                                 // Opera returns 0 when status is 304
    631630                                ( xhr.status >= 200 && xhr.status < 300 ) ||
    632                                 xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
     631                                ( xhr.status === 304 || xhr.status === 1223 ||
     632                                  // Opera returns 0 when status is 304
     633                                  ( xhr.status === 0 && jQuery.browser.opera ) );
    633634                } catch(e) {}
    634635
    635636                return false;
    jQuery.extend( jQuery.ajax, { 
    649650                }
    650651
    651652                // Opera returns 0 when status is 304
    652                 return xhr.status === 304 || xhr.status === 0;
     653                return xhr.status === 304 || ( xhr.status === 0 && jQuery.browser.opera );
    653654        },
    654655
    655656        httpData: function( xhr, type, s ) {