Bug Tracker

Modify

Ticket #8342 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 2 years ago by jitter

  • Priority changed from undecided to low
  • Resolution set to duplicate
  • Status changed from new to closed
  • Component changed from unfiled to ajax
  • Milestone changed from 1.next to 1.5.1

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)

comment:2 Changed 2 years ago by jitter

Duplicate of #8125.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.