Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajax-abstraction

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajax-abstraction

A tiny XMLHTTPRequest abstraction.

  • 2.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Code Climate

Ajax

A tiny XMLHTTPRequest abstraction, 2kb minified and a bit less than 900b minified and gzip.

Why?

I just want to use jQuery Ajax like methods, but without loading ALL jQuery.

Why not use XYZ lib?

Because I made no reasearch before building this :bowtie:.

Include in your project

You can just download it from this repo. But I'd recommend you to use bower method:

bower install Ajax

You can also use npm:

npm install ajax-abstraction

Yeap, not same name. It was already taken on NPM. Life is not so beautiful =/

How to use

If you know how to use jQuery Ajax methods, you know how to use this. See below:

Ajax.call({
	url: '/foo',
	success: function(data) {
		// my success function
	}
});

This lib supports UMD. So, import this via AMD, CommonJS or importing min script in you HTML and using as window global.

It's possible to use setup method for setting default options. The same parameters can be passed.

Options

  • contentType [string]:

    • The content type of your request;
    • default: 'application/x-www-form-urlencoded; charset=UTF-8'.
  • context [object]:

    • Context where your callbacks will be executed;
    • default: window
  • data [string]:

    • Data that will be passed on body of the request.
  • dataType [string]:

    • Format that your data will be returned;
    • default: JSON
  • fail [function]:

    • Function that will be called if your function doesn't return code 200.
  • headers [json]:

    • Headers of your request. This must be an Javascript Object.
  • method [string]:

    • HTTP method used on this request;
    • default: 'GET'.
  • success [function]:

    • Function that will be called if your function returns code 200.

License

GPL 3 (full copy shipped with code)

Keywords

FAQs

Package last updated on 02 Feb 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc