Skip to main content

Bug Tracker

Side navigation

#6518 closed bug (invalid)

Opened May 03, 2010 08:25PM UTC

Closed October 01, 2010 02:08AM UTC

.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

if ( status === "success" || 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)
  • Loaded.php (0.2 KB) - added by rsinton May 03, 2010 08:26PM UTC.

    Loaded.php (called by ajax function)

  • test30.html (0.8 KB) - added by rsinton May 03, 2010 08:25PM UTC.

    Sample Code

Change History (4)

Changed May 03, 2010 08:28PM UTC by rsinton comment:1

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);
}

Changed May 03, 2010 09:53PM UTC by rsinton comment:2

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.

Changed May 04, 2010 07:46AM UTC by rsinton comment:3

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.

Changed October 01, 2010 02:08AM UTC by addyosmani comment:4

priority: → undecided
resolution: → invalid
status: newclosed

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.