Skip to content

iiyo/easy-ajax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easy-ajax

Simple wrapper functions for XMLHttpRequest.

Installation

npm install easy-ajax

Usage

var ajax = require("easy-ajax");
var requestObject = ajax(method, url, options, then);
var requestObject = ajax(method, url, then);
var requestObject = ajax.get(url, options, then);
var requestObject = ajax.get(url, then);
var requestObject = ajax.post(url, data, options, then);
var requestObject = ajax.post(url, data, then);
  • requestObject: XMLHttpRequest instance.
  • method: HTTP method: "GET", "POST", ...
  • options: Configuration object:
    • timeout: Timeout in ms.
    • data: Data to send (when POSTing).
    • randomize: Add a random query string to prevent caching?
    • before: A function to call after opening and before sending the request; called with the XMLHttpRequest object as the first argument.
    • headers: A hash object with additional headers to set; the keys are the header names, the values the values to set for the header.
  • then: Callback for when the request is finished.
function then (error, requestObject) { /* ... */ }
  • error: An Error instance or null when there are no errors.
  • requestObject: The finished XMLHttpRequest instance.

About

Simple wrapper functions for XMLHttpRequest.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published