Skip to main content

Bug Tracker

Side navigation

#6748 closed bug (duplicate)

Opened July 01, 2010 01:00AM UTC

Closed September 30, 2010 03:59PM UTC

Last modified March 15, 2012 01:08PM UTC

xhr.status === 0 should be treated as 304 (Not Modified) only in Opera

Reported by: benjamn Owned by:
Priority: undecided Milestone: 1.4.3
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Consider the boolean expression returned by httpSuccess():

    return !xhr.status && location.protocol === "file:" ||
        // Opera returns 0 when status is 304
        ( xhr.status >= 200 && xhr.status < 300 ) ||
        xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;

Opera may indeed return 0 when the status should be 304, but other browsers (notably, Chrome Mac) return 0 as a result of certain errors (e.g., same-origin restrictions).

Treating xhr.status === 0 as success is a special case that should apply only in Opera. This subtle difference in behavior could be keeping folks from upgrading from 1.3.x, so it should be fixed if possible.

Attachments (1)
Change History (9)

Changed July 02, 2010 02:42AM UTC by dmethvin comment:1

Hi, do you have any further information on this bug? We try hard to avoid use of jQuery.browser. Is there any doc or acknowledgment by Opera about it that you can find?

Changed July 02, 2010 06:24PM UTC by benjamn comment:2

Replying to [comment:1 dmethvin]:

Hi, do you have any further information on this bug? We try hard to avoid use of jQuery.browser. Is there any doc or acknowledgment by Opera about it that you can find?

The original code contains an explicit special case for Opera, as indicated by the existing comment. Treating xhr.status === 0 as success in any browser other than Opera is incorrect. I would be happy for jQuery to drop support for this Opera quirk by removing the xhr.status === 0 clause altogether, but if we're trying to pander to a single browser's bug, then we should at least be precise about it. If there is any acceptable use of jQuery.browser.opera, this is such a case.

Changed July 02, 2010 06:27PM UTC by benjamn comment:3

Changed July 11, 2010 03:24PM UTC by execjosh comment:4

Replying to [comment:2 benjamn]:

Replying to [comment:1 dmethvin]: > Hi, do you have any further information on this bug? We try hard to avoid use of jQuery.browser. Is there any doc or acknowledgment by Opera about it that you can find? The original code contains an explicit special case for Opera, as indicated by the existing comment. Treating xhr.status === 0 as success in any browser other than Opera is incorrect. I would be happy for jQuery to drop support for this Opera quirk by removing the xhr.status === 0 clause altogether, but if we're trying to pander to a single browser's bug, then we should at least be precise about it. If there is any acceptable use of jQuery.browser.opera, this is such a case.

I agree that there is a need to be precise ''in code'' and not only ''in comments''.

In my tests, I have found that this issue affects at least:

  • Chrome (v5.0.375.99)
  • Firefox (v3.6.6)

Test Code

Setup

1. Make code accessible via http from ''server''

1. Load html file in browser on ''client''

a. Ensure ''client'' and ''server'' are different machines

a. Ensure direct connection (i.e., _no proxy_) between ''client'' and ''server''

a. I used VirtualBox locally, connected via host-only network

1. Sever connection betweent ''client'' and ''server''

1. Press button and wait for result

Expected Results

OnError["504", "error", ""]

Actual Results

OnSuccess["0", "success", ""]

Code

filename: ''jquery-bug-6748.html''

<!DOCTYPE html>
<title>jQuery bug #6748</title>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<input id="b" type="button" value="jQuery-bug-6748">
<div id="p"></div>
<script>
(function($){
  $(document).ready(function(){
    function f(n,x,s,e){$('#p').html(['<div>',n,'["',x.status,'", "',s,'", "',e,'"]</div>'].join(""))}
    $('#b').click(function(){
      $.ajax({
        async:true,
        cache:false,
        error:function(x,s,e){f('OnError',x,s,e)},
        success:function(d,s,x){f('OnSuccess',x,s)}
      });
    });
  });
})(jQuery);
</script>

Changed July 11, 2010 03:30PM UTC by execjosh comment:5

Expected Results OnError["504", "error", ""]

Woops, this was generated using a proxy...

It should read as follows OnError["0","error",""].

Changed August 23, 2010 04:30AM UTC by curiousdannii comment:6

Duplicate of #6060

Changed September 22, 2010 01:06AM UTC by curiousdannii comment:7

Please close as #6060 has been fixed.

Changed September 30, 2010 03:59PM UTC by dmethvin comment:8

priority: → undecided
resolution: → duplicate
status: newclosed

Changed November 29, 2010 04:55PM UTC by rwaldron comment:9

#7647 is a duplicate of this ticket.