Opened 13 years ago
Closed 12 years ago
#6518 closed bug (invalid)
.ajax() ifModified option -- behaviour changed in v1.4.2
Reported by: | rsinton | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | ajax | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
As described by jQuery forum user alxblog, the ifModified option seems to have stopped working between v1.3.2 and v1.4.2.
Forum posting with good sample code: http://forum.jquery.com/topic/jquery-1-3-2-update-to-1-4-2-ifmodified-option-doesn-t-still-work
The sample code works as expected in v1.3.2, delivering "notmodified" as the textStatus parameter to the .ajax() call's error function. This matches the behaviour described in the documentation for .ajax().
In v1.4.2, however, the success function is called every time.
I can see that the relevant jQuery code for this functionality has changed quite a bit between those versions. Looks like the problem is here:
Make sure that the request was successful or notmodified
status === "notmodified" ) { |
JSONP handles its own success callback if ( !jsonp ) {
success();
}
} else {
jQuery.handleError(s, xhr, status, errMsg);
}
i.e. "notmodified" is now being treated as a success rather than an error.
Attachments (2)
Change History (6)
Changed 13 years ago by
Attachment: | test30.html added |
---|
comment:1 Changed 13 years ago by
Oops, sorry. Properly-formatted code this time:
// Make sure that the request was successful or notmodified if ( status === "success" || status === "notmodified" ) { // JSONP handles its own success callback if ( !jsonp ) { success(); } } else { jQuery.handleError(s, xhr, status, errMsg); }
comment:2 Changed 13 years ago by
Update: I think the issue is actually not there, but in the change to the httpNotModified function.
Final return in v1.3.2 was:
return xhr.status == 304 || xhrRes == jQuery.lastModified[url];
but is now:
return xhr.status === 304 || xhr.status === 0;
i.e. only xhr.status is being tested.
Debugging in Safari, I find that the xhr.status is 200 at this point, but
xhr.getResponseHeader("Last-Modified") == jQuery.lastModified[s.url]
does evaluate true.
comment:3 Changed 13 years ago by
Ah, mea culpa. I have just realised that the sample code is returning the last-modified date, but not returning an HTTP 304 status code.
It is a change in behaviour vs v1.3.2, but if I expect that v1.4.2 is actually taking a more correct approach.
Please close.
comment:4 Changed 12 years ago by
Priority: | → undecided |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Closing as this issue has been resolved in 1.4.2. ifModified hasn't stopped working but has actually been updated appropriately since the 1.3.2 release. I believe the original ticket submitter was looking at an incorrect output in their example which may have prompted the original look at ifModified's behaviour.
Sample Code