Skip to content

Commit

Permalink
Add a flag to verify if a browser supports some form of XHR request. …
Browse files Browse the repository at this point in the history
…Fixes #7030.
  • Loading branch information
jeresig committed Sep 13, 2010
1 parent 1ed4051 commit 959c20f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ajax.js
Expand Up @@ -686,6 +686,9 @@ jQuery.extend( jQuery.ajax, {

});

// Does this browser support XHR requests?
jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();

// For backwards compatibility
jQuery.extend( jQuery.ajax );

Expand Down

2 comments on commit 959c20f

@jdalton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is it safe to assume if window.XMLHttpRequest exists there won't be some kind of error when calling xhr() should there be a try-catch for this flag ?

@jeresig
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably a safe assumption - we don't wrap the xhr() call in a try/catch now, inside ajax(), and we don't have problems. Most of the exceptions occur either with setting headers or sending.

Please sign in to comment.