Skip to content

Simplify XHR detection #1967

Closed
Closed
@FarSeeing

Description

@FarSeeing

This is the XMLHttpRequest object detection code:

https://github.com/jquery/jquery/blob/master/src/ajax/xhr.js

jQuery.ajaxSettings.xhr = function() {
    try {
        return new XMLHttpRequest();
    } catch ( e ) {}
};
...
xhrSupported = jQuery.ajaxSettings.xhr();
...
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported;

support.ajax is used nowhere in the code and is not documented, XMLHttpRequest object is supported in all modern browsers (including Android 2.3, iOS 6.1, Opera 12 and IE 9 — caniuse.com).
Why not remove xhrSupported variable together with support.ajax and try-catch block?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions