argon/storage/json_rest.js
function _sendRequest(requestObj, callback) {
        var Storage, ajaxConfig;

        Storage = this;

        ajaxConfig = {
            url         : requestObj.config.url,
            type        : requestObj.config.type || this.REQUEST_TYPE_GET,
            contentType : requestObj.config.contentType || 'application/json',
            global      : false,
            async       : true,
            cache       : false,
            complete    : function(xhr, message){
                Storage._processResponse(xhr, message, callback);
            }
        };

        if (ajaxConfig.type != Argon.Storage.JsonRest.REQUEST_TYPE_GET) {
            ajaxConfig.data = JSON.stringify(requestObj.data);
        }

        if (ajaxConfig.type == this.REQUEST_TYPE_PUT || ajaxConfig.type == this.REQUEST_TYPE_DELETE) {
            ajaxConfig.beforeSend = function(xhr) {
                xhr.setRequestHeader("X-Http-Method-Override", ajaxConfig.type);
            };
            ajaxConfig.type = this.REQUEST_TYPE_POST;
        }

        $.ajax(ajaxConfig);

        return this;
    }
function _sendRequest(requestObj, callback) {
        var Storage, ajaxConfig;

        Storage = this;

        ajaxConfig = {
            url         : requestObj.config.url,
            type        : requestObj.config.type || this.REQUEST_TYPE_GET,
            contentType : requestObj.config.contentType || 'application/json',
            global      : false,
            async       : true,
            cache       : false,
            complete    : function(xhr, message){
                Storage._processResponse(xhr, message, callback);
            }
        };

        if (ajaxConfig.type != Argon.Storage.JsonRest.REQUEST_TYPE_GET) {
            ajaxConfig.data = JSON.stringify(requestObj.data);
        }

        if (ajaxConfig.type == this.REQUEST_TYPE_PUT || ajaxConfig.type == this.REQUEST_TYPE_DELETE) {
            ajaxConfig.beforeSend = function(xhr) {
                xhr.setRequestHeader("X-Http-Method-Override", ajaxConfig.type);
            };
            ajaxConfig.type = this.REQUEST_TYPE_POST;
        }

        $.ajax(ajaxConfig);

        return this;
    }
function _sendRequest ( requestObj , callback ) { var Storage , ajaxConfig ; Storage = this ; ajaxConfig = { url : requestObj . config . url , type : requestObj . config . type || this . REQUEST_TYPE_GET , contentType : requestObj . config . contentType || 'application/json' , global : false , async : true , cache : false , complete : function ( xhr , message ) { Storage . _processResponse ( xhr , message , callback ) ; } } ; if ( ajaxConfig . type != Argon . Storage . JsonRest . REQUEST_TYPE_GET ) { ajaxConfig . data = JSON . stringify ( requestObj . data ) ; } if ( ajaxConfig . type == this . REQUEST_TYPE_PUT || ajaxConfig . type == this . REQUEST_TYPE_DELETE ) { ajaxConfig . beforeSend = function ( xhr ) { xhr . setRequestHeader ( "X-Http-Method-Override" , ajaxConfig . type ) ; } ; ajaxConfig . type = this . REQUEST_TYPE_POST ; } $ . ajax ( ajaxConfig ) ; return this ; }
Internal implementation of the communication sequence with the service
All requests at some point rely on this method to format the data and send the request to the service
@method _sendRequest <public, static> [Function]
@argument requestObj
@argument callback the function to execute when the process finishes
@return Argon.Storage.JsonRest
Internal implementation of the communication sequence with the service All requests at some point rely on this method to format the data and send the request to the service