Skip to content

native abort does not abort jqXHR in 2.1.x #2079

Closed
@salomvary

Description

If the native XMLHttpRequest is aborted (eg. calling abort(), suspending the computer or unloading the page) jqXHR does not fire any callbacks. Expected: fire error and complete callbacks.

Test code to reproduce:

var wrappedXhr;
$.ajax({
    xhr: function() {
      wrappedXhr = jQuery.ajaxSettings.xhr();  
      return wrappedXhr;
    },
    url: '/echo/json/?delay=100',
    complete: console.log.bind(console, 'jQuery complete'),
    error: console.log.bind(console, 'jQuery error'),
    success: console.log.bind(console, 'jQuery success')
})
.progress(console.log.bind(console, 'jQuery progress'))
.fail(console.log.bind(console, 'jQuery fail'))
.always(console.log.bind(console, 'jQuery always'));
wrappedXhr.abort();

Test code on jsfiddle.

Note: the bug is not present in 1.11.x and 3.0 (master) versions.

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions