PDA

View Full Version : Save previous response of request



Wolfie
20 Sep 2010, 12:18 AM
Hi all

I have this code :



var config = {test_title : 'Title',
change_text : 'change',
no_change_text: 'no change'}

//config.responseArray = new Array();
config.responseArray['new'] = '';
//config.responseArray['old'] = '';

VCC.askPermissions = function(config){
VCC.Ajax({
url: App.baseUrl + '/utils/empty',
onSuccess: function(response){
var resp = Ext.decode(response.responseText);

config.responseArray['new'] = resp;

if(config.responseArray['old'] != config.responseArray['new']){
Ext.Msg.alert(config.test_title, config.change_text);
config.responseArray['old'] = resp;
} else {
Ext.Msg.alert(config.test_title, config.no_change_text);
config.responseArray['old'] = resp;
}


},
onFailure : function(){

}
});
}

var task = {
run: VCC.askPermissions.createDelegate(this, [config]),
interval: 10000 //10 second
}

Ext.TaskMgr.start(task);


The thing is that I want to save the previous repsponse of the Ajax request but I don't really know how.

I was trying to pass the array to the function, but of course each time the function is executed, the array is constructing itself empty, so it is not good idea of doing my taks, any sugestions ?

jay@moduscreate.com
21 Sep 2010, 5:06 AM
It seems that you have your own Ajax interface method (VCC.Ajax), why not set a property on VCC.Ajax itself? VCC.Ajax.prevResponse = response.responseText (or whatever)