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

simple-ajax

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-ajax

Simple ajax module

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
decreased by-2.97%
Maintainers
1
Weekly downloads
 
Created
Source

#simple-ajax

Simple ajax module.

##Usage

var Ajax = require('simple-ajax');

var ajax = new Ajax('https://api.github.com/users/octocat/orgs');

ajax.on('success', function(event) {
    console.log('success', event);
});

ajax.send();

###Or Provide Options Object

var ajax = new Ajax({
        url: 'https://api.github.com/users/octocat/orgs',
        methos: 'GET',
        headers: {
            myCustomHeader: 'my custom header value'
        }
    });

Available Options

{
    url: 'url to request',
    method: 'method to request with',
    cors: 'is CORS request (only needed for IE)',
    cache: 'set to false to explicitly break cache',
    data: 'JSON data to be sent with request',
    dataType: 'type of expected response',
    contentType: 'if JSON will try to parse response data',
    requestedWith: 'defaults to XMLHttpRequest',
    auth: 'used to set the Authorization header',
    headers: 'custom headers object'
}

###Add Event Listeners

ajax.on('success', function(event) {
    console.log('success', event);
});

ajax.on('error', function(event) {
    console.log('error', event);
});

ajax.on('complete', function(event) {
    console.log('complete', event);
});

###Send Request

ajax.send();

Keywords

FAQs

Package last updated on 02 Apr 2015

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