1.1.0 • Published 9 years ago
easy-ajax v1.1.0
easy-ajax
Simple wrapper functions for XMLHttpRequest.
Installation
npm install easy-ajaxUsage
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: AnErrorinstance ornullwhen there are no errors.requestObject: The finishedXMLHttpRequestinstance.
1.1.0
9 years ago
1.0.0-final.1512141736
10 years ago