define([ 'Ajax' ], function( Ajax ) {
var ajax = new Ajax();
...
});
var Ajax = require( '@fdaciuk/ajax' );
var ajax = new Ajax();
...
var ajax = new window.Ajax();
or
var ajax = new Ajax();
Ajax
constructor is deprecated and will be removed in v2.0.0
. Use ajax()
function (lowecase version) without new
keyword instead.
Enjoy ;)
Promise that returns if the request was successful.
done
is deprecated. Use then
instead.
ajax().get( '/api/users' ).done(function( response, xhr ) {
// Do something
});
Promise that returns if the request has an error.
error
is deprecated. Use catch
instead.
ajax().post( '/api/users', { slug: 'john' }).error(function( response, xhr ) {
// Do something
});