Вход Регистрация
Файл: static/plugins/base/js/ajax_utils.js
Строк: 71
<?php
var PEEP_Component_Ajax = function(urlResponder) {
    
this.urlResponder urlResponder;
    
this.queue = [];
};

PEEP_Component_Ajax.prototype = {
    
    
addRequest: function(commanddatasuccess) {
        var 
request = {
            
commandcommand,
            
datadata
        
};
        
this.queue.push({
            
requestrequest,
            
successsuccess
        
});
    },
        
    
sendQueue: function(successCallback) {
        
        if ( !
this.queue.length ) {
            return;
        }
        
        var 
request = [];
        var 
success = {};
        
        for (var 
i in this.queue) {
            
this.queue[i].request.commandId i;
            
request.push(this.queue[i].request);
            if (
this.queue[i].success) {
                
success[i] = this.queue[i].success;
            }
        }
        
        
this._ajaxSend(requestsuccesssuccessCallback)
                
        
this.queue = [];
    },

        
_ajaxSend: function(requestcallbackStackresultCallback) {
            var 
jsonRequest encodeURIComponentJSON.stringify(request) );
        
            var 
ajaxOptions = {
                    
urlthis.urlResponder,
                    
dataType'json',
                    
type'POST',
                    
data: {requestjsonRequest},
                    
success: function(result) {
                            if ( 
typeof result !== "object" ) {
                                var 
fb = new PEEP_FloatBox({
                                    
$title'Incorrect responce',
                                    
$contentsresult.toString(),
                                    
width'100%'
                                
});
                            }
                            var 
sharedData = {};
                            $.
each(result.responseQueue, function(commandIDresultData) {
                                    if (
callbackStack[commandID]) {
                                        
callbackStack[commandID](resultDatasharedData);
                                    }
                            });

                            $.
each(result.debug, function() {
                                    if (
console) {
                                            
console.log(this);
                                    } else {
                                            
alert(JSON.stringify(this));
                                    }
                            });
                            
                            if (
resultCallback) {
                                    
resultCallback(resultsharedData);
                            }
                    },
                    
error: function(r) {
                        var 
fb = new PEEP_FloatBox({
                            
$title'Incorrect responce',
                            
$contentsr.responseText,
                            
width'100%'
                        
});
                    }
                };

                $.
ajax(ajaxOptions);
        },

        
send: function(commanddatasuccess) {
            
            var 
request = {
                
commandcommand,
                
datadata,
                
commandId0
            
};

            
this._ajaxSend([request],[success] );
        }
}
?>
Онлайн: 2
Реклама