Socket
Socket
Sign inDemoInstall

fl-backbone.nativeajax

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fl-backbone.nativeajax

A Backbone.Ajax function powered by native XHR methods


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source
Fork of Backbone.NativeAjax that doesn't consider 404s errors

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:

  • Accepts success and error callbacks
  • Set headers with a headers object
  • beforeSend

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:

  • The ajax function accepts a success and error callbacks. To return a promise object, set a global Promise or Backbone.ajax.Promise.
  • Unlike jQuery, we don't automatically set the X-Requested-With header, so things like Rails' request.xhr? will break. If you need it, you can pass it in yourself.

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

FAQs

Last updated on 17 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc