Sometimes you'll only need one of these, sometimes you'll want both (in an isomorphic/universal app for instance).
Either way, you'll probably want a nice concise syntax. Most developers find
XMLHttpRequest API a little too verbose for their taste.
Many developers use jQuery, but if you only need the AJAX features, loading the whole library may seem like a waste.
|Chrome & Firefox1||All Browsers||Node||Concise Syntax||Promises||Native2||Single Purpose3||Formal Specification|
|Chrome & Firefox1||All Browsers||Node|
|Concise Syntax||Promises||Native2||Single Purpose3||Formal Specification|
fetch() is the new standard. It's already supported in Chrome and Firefox - so if don't need IE or Safari support you can use it today without any library at all. I suggest you start here.
If you need support for more browsers I suggest GitHub's Fetch polyfill. You get to use the new standard now, and eventually you can delete the polyfill library when more browsers support Fetch.
If you're using node.js you can still use Fetch, but you need the node-fetch library.
If your code is universal there's a Fetch library for that too:
node-fetch and the
If you are already using jQuery, just use
$.ajax. No additional
libraries needed, and you'll have good support in most browsers. Using the
Fetch polyfill would add unnecessary k-weight to your code.