Skip to main content

Bug Tracker

Side navigation

#8342 closed bug (duplicate)

Opened February 21, 2011 06:29PM UTC

Closed February 21, 2011 06:42PM UTC

Last modified February 21, 2011 06:43PM UTC

Ajax error event fires when correct response received if page is loaded with file: protocol

Reported by: johnhunter Owned by:
Priority: low Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

Browser affected:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4

Description:

When accessing a page in the loacal file system (file: protocol) JQuery-1.5 fires the error callback on Ajax GET request despite receiving a valid response. This problem does not occur over http:, or over file: with JQuery-1.4.x

Relevant section of code to reproduce:


$.ajax({
    type: "GET",
    url: 'response.html',
    
    success: function () {
		console.log('success ', arguments);
    },
    
    error: function () {
		console.log('error ', arguments);
    },
    
    complete: function (xhr, status) {
        if (status === 'error' || !xhr.responseText) {
        }
        else {
			out.append(xhr.responseText);
        }
		console.log('complete ', arguments);
    }
});

Steps to reproduce:

1. Save a local copy of the test case: https://gist.github.com/837428

2. Load the jquery-ajax-callback-test.html in the browser via the file: protocol.

3. Check the result.html content is displayed.

4. Examine the console log trace.

Expected result:

Response text 'Success' is displayed.

Console trace shows both success and complete events fired.

Actual result:

No response text displayed.

Console trace shows error event fired.

Console trace shows complete event fired, passed xhr object contains correct responseText, statusText is an empty string.

Attachments (0)
Change History (2)

Changed February 21, 2011 06:42PM UTC by jitter comment:1

component: unfiledajax
milestone: 1.next1.5.1
priority: undecidedlow
resolution: → duplicate
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case!

This has already been fixed and will be in jQuery 1.5.1 (you can verify by trying the current 1.5.1rc1)

Changed February 21, 2011 06:43PM UTC by jitter comment:2

Duplicate of #8125.