Ticket #5872 (closed bug: duplicate)
ajax calls succes instead of error on server error
| Reported by: | arj | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.1 |
| Component: | ajax | Version: | 1.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Way to reproduce:
request a page, and on load do a local long-polling-request kill the server the request callback is success?
I then tried on the same page to run:
$.ajax({type: "GET", url:"http://localhost:6666/", success: function(a, b) { console.log("got success"); }, error: function() { console.log("error"); }});
Gives: "got success"
http://localhost:6666/ is the url that the page is served from.
But loading up a different site that also has jquery loaded and running the same code in firebug results in a "error" in console.
Change History
comment:2 Changed 3 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
Sorry but I cannot understand the description here. Can you post a complete test case with code?
comment:3 Changed 3 years ago by arj
- Status changed from closed to reopened
- Resolution invalid deleted
I can confirm that it is a bug in jquery 1.4. Going back to jquery 1.3.2 fixes.
To reproduce do the following:
Have a server end where you take a long time to respond to a request. Sleeping will work.
Request the url using:
$.ajax({type: "GET", url:"http://localhost:6666/takesVeryLong", success: function(a, b) { console.log("got success"); }, error: function() { console.log("error"); }});
in something like firebug. Then click somewhere else and then escape, this will cancel the request. Firebug now says success even though it's clearly a failure. Please note that the url ( http://localhost:6666/) needs to be the same as the page was served from.
comment:4 Changed 3 years ago by austinjackson
I can reproduce this error in 1.4.1 by:
- disabling internet connection on client
- initializing the ajax request
- i get success, when I should get error
reverting to 1.3.2 solves the problem.
comment:5 Changed 3 years ago by austinjackson
The code:
$.ajax({ dataType: 'text', cache: false, timeout: 10000, url: '/', data: {'function': 'sync'}, success: function() { alert('success'); }, error: function() { alert('error'); } });
comment:6 Changed 3 years ago by arj
Milestone: 1.4.1 needs to be updated and it seems that I don't have the powers to do it.
comment:7 Changed 3 years ago by guy
Looks like this ticket has been duplicated #5968. The duplicate is filed under the ajax Component.
comment:8 Changed 3 years ago by arj
The patch in http://dev.jquery.com/ticket/6060 does seem to work.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

One more thing, in firebug on localhost:6666, when I run the .ajax myself, I get:
XMLHttpRequest
while running it on another site gives:
XMLHttpRequest readyState=1 multipart=false
The other site is running jQuery 1.3.2, so not sure if that's is the difference I'm seeing.