A simple, jQuery-based Ajax tool
This is a generic AJAX class that can be reused throughout your app. I normally place this within a single file like com.chrisjmendez.AjaxRequest.js
, load the script and boom, start making requests.
/**
* Ajax Request
* @author @chrismendezinla
*
*/
var AjaxRequest = {
start: function( xhrInstance ){
},
error: function ( xhrInstance, message, optional ){
},
complete: function ( xhrInstance, status ){
updateLoaderStatus( "", false );
},
init: function( url, successCallback){
//console.log( "ajaxRequest", url );
$.ajax({
url: url,
type: 'GET',
encoding:"UTF-8",
beforeSend: this.start,
success: successCallback,
error: this.error,
complete: this.complete
});
}
}
function updateLoaderStatus( message, showPreloader ){
}
AjaxRequest.init("http://api.domain.com")