Edit: 5/4/2020, I moved this to https://www.aligneddev.net/blog/2020/ajaxpromiseswithoutjquery/
I’m trying to move away from jQuery, since I’m using Knockout and AngularJS more all the time. I’ve always done my AJAX calls with the useful jQuery $.ajax( method.
Searching for “ajax without jquery” brings up a lot of results, but they all include how to do it with jQuery.
First a friend found a tutorial on ES6 promises on HTML5 rocks that included an example of “Promisifying XMLHttpRequest”. Since promises aren’t in all browsers yet (IE and Android Browser) you can polyfill with es6-promise. Or use Q or Bluebird for a promise implementation. Angular JS has it’s own $http and $q to handle this.
There is also a question on StackOverflow that I added this answer to.
Wrap that in a dataService.js file and I’ll be well on my way to no longer needing jQuery for Ajax calls and still have promises!
Update: This project on Github has a simple wrapper of XHR with promises added in.
Update 2: Fetch is going to be an XMLHttpRequest replacer though it’s a ways off in browser support.