Skip to content
/ ajax-amd Public

Ajax.js is a library that helps ajax request. This library uses amd structure.

License

Notifications You must be signed in to change notification settings

elo7/ajax-amd

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date
Jun 19, 2015
May 4, 2020
May 4, 2020
Jun 19, 2015
Sep 19, 2018
Apr 17, 2017
Apr 17, 2017
Jul 4, 2017
May 4, 2020
May 4, 2020
Jul 5, 2021
Feb 1, 2021
May 4, 2020

Repository files navigation

Ajax-amd

Ajax-amd is an ajax library

Ajax.js is a library that helps making ajax requests on modern (IE >= 10) browsers. This library uses amd structure.

Build Status

Install

Install with NPM: npm install elo7-ajax-amd

Dependency

Elo7-ajax-amd depends on an amd implementation. We suggest async-define implementation for dependency lookup. You only need to install it with NPM and load elo7-ajax-amd file on your page.

Methods

get

.get(url, data [,callbacks] [,config])

Description:

Executes an ajax request using get http method.

Sample:
define(['ajax'], function(ajax) {
	ajax.get('http://domain.com/ajax', {
		'data': 'value'
	}, {
		'success': function(response [,xhr]) {
			// success callback
		},
		'error': function(response [,xhr]) {
			// error callback
		},
		'complete': function([xhr]) {
			// complete callback
		}
	}, {
		retries: 1,     // number of retries
		timeout: 1000,  // timeout in ms
		async: true    // asynchronous
	});
});

post

.post(url, data [,callbacks] [,config])

Description:

Executes an ajax request using post http method.

Sample:
define(['ajax'], function(ajax) {
	ajax.post('http://domain.com/ajax', {
		'data': 'value'
	}, {
		'success': function(response [,xhr]) {
			// success callback
		},
		'error': function(response [,xhr]) {
			// error callback
		},
		'complete': function([xhr]) {
			// complete callback
		}
	}, {
		retries: 1,     // number of retries
		timeout: 1000,  // timeout in ms
		async: true    // asynchronous
	});
});

put

.put(url, data [,callbacks] [,config])

Description:

Executes an ajax request using put http method.

delete

.delete(url, data [,callbacks] [,config])

Description:

Executes an ajax request using delete http method.

serializeObject

.serializeObject(form)

Description:

Serializes form fields to json. It can be used as data to the ajax function.

Sample:
define(['ajax'], function(ajax) {
	var serializedForm = ajax.serializeObject(document.querySelector('form'));
});

License

Elo7-ajax-amd is released under the BSD. Have at it.


Copyright ©️ 2017 Elo7