1.5.1 • Published 4 years ago

jajax.js v1.5.1

Weekly downloads
18
License
-
Repository
github
Last release
4 years ago

jAJAX Build Status

jQuery-like AJAX method for multiple environments: browser, chrome-extension, safari-extension, firefox-extension.

You can use it even in Node.js with node-XMLHttpRequest.

Usage

jajax(options: object, ondone: function, onerror: function)
// or in Promise mode
jajax(options: object).then(onresolve, onreject)
/*  where
 *    options is "url" or {url:"url", dataType:"type", method: "GET", ...}, similar to jQuery.ajax(options)
 *
 *    function ondone(result, statusText, xhr[, response]);
 *    function onerror(xhr, type: "error"|"parsererror"|"abort"|"timeout"|"xhr", error[, response]);
 * 
 *    Note: In Firefox there is response object instead of XHR, xhr is a plain object substitute 
 *    Note 2: The error object of onreject also has error.xhr and error.response properties.
 */

The following expression could easily replace jAJAX when jQuery is present:

var jajax = function (options, ondone, onerror) {
    return jQuery.ajax(options).done(ondone).fail(onerror)
};

For more options see jQuery.ajax().

Features

  • No external dependencies (no jQeury required)
  • Small footprint (~ 2.5Kb minified and gziped)
  • Easy to use (see jQuery.ajax())
  • Works in Browser Extensions as well (tested in chrome-extension, safari-extension, firefox-extension)
  • Can be used as a drop in replacement for jQuery.ajax()

License

MIT

Happy coding!

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.3

5 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

8 years ago

1.1.2

9 years ago

1.1.1

9 years ago