Home

Awesome

Backbone.NativeAjax

A drop-in replacement for Backbone.Ajax that uses only native XMLHttpRequest methods for sync. It has no dependency on jQuery.

You might consider using the window.fetch pollyfill coupled with a simple plugin for Backbone instead of this project if you need better Promise or header support.

To Use:

Load Backbone.NativeAjax with your favorite module loader or add as a script tag after you have loaded Backbone in the page.

If loading with AMD or CommonJS you should set Backbone.ajax yourself:

// AMD
define(['backbone', 'nativeajax'], function(Backbone, ajax) {
  Backbone.ajax = ajax;
});

// CommonJS
var Backbone = require('backbone');
Backbone.ajax = require('backbone.nativeajax');

Features:

Requirements:

NativeAjax uses XMLHttpRequest which is supported in modern browsers. See the compatibility chart.

It also makes use of Function.prototype.bind which can be easily pollyfilled in older environments.

Set a Promise object on the global or on Backbone.ajax to return a promise.

Notes:

Uses code from Exoskeleton. See that project for more information and other features.