File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -629,9 +629,11 @@ jQuery.extend( jQuery.ajax, {
629
629
try {
630
630
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
631
631
return ! xhr . status && location . protocol === "file:" ||
632
- // Opera returns 0 when status is 304
633
632
( xhr . status >= 200 && xhr . status < 300 ) ||
634
- xhr . status === 304 || xhr . status === 1223 || xhr . status === 0 ;
633
+ xhr . status === 304 || xhr . status === 1223 ||
634
+ // Opera returns a status of 0 for redirects -
635
+ // We can detect this by the fact that Opera also doesn't return any headers
636
+ xhr . status === 0 && ! xhr . getAllResponseHeaders ( ) ;
635
637
} catch ( e ) { }
636
638
637
639
return false ;
@@ -651,7 +653,7 @@ jQuery.extend( jQuery.ajax, {
651
653
}
652
654
653
655
// Opera returns 0 when status is 304
654
- return xhr . status === 304 || xhr . status === 0 ;
656
+ return xhr . status === 304 || xhr . status === 0 && ! xhr . getAllResponseHeaders ( ) ;
655
657
} ,
656
658
657
659
httpData : function ( xhr , type , s ) {
Original file line number Diff line number Diff line change
1
+ <?php header ('HTTP/1.0 304 Not Modified ' ); exit ; ?>
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ test("jQuery.ajax() - error callbacks", function() {
68
68
} ) ;
69
69
} ) ;
70
70
71
+ test ( ".ajax() - 304" , function ( ) {
72
+ expect ( 1 ) ;
73
+ stop ( ) ;
74
+
75
+ jQuery . ajax ( {
76
+ url : url ( "data/notmodified.php" ) ,
77
+ success : function ( ) { ok ( true , "304 ok" ) ; } ,
78
+ error : function ( ) { ok ( false , "304 not ok " ) ; } ,
79
+ complete : function ( xhr ) { start ( ) ; }
80
+ } ) ;
81
+ } ) ;
82
+
71
83
test ( ".load()) - 404 error callbacks" , function ( ) {
72
84
expect ( 6 ) ;
73
85
stop ( ) ;
You can’t perform that action at this time.
0 commit comments