extjs ajax 返回值,extjs return ajax response

I need to assign the ajax response to a global variable so that i can use it thoughout my application. The obvious problem is that ajax requests are async thus complicating things.

I have tried to initialize an object before the ajax call, then assigning the response fron inside the success but that didn't work either.

Any ideas?

Example code

var p = {};

loadLang('en');

function loadLang(code) {

Ext.Ajax.request({

url : '/LoadLanguage.html',

method : 'POST',

params :{'code':code},

timeout : 250,

success : function(response, opts) {

obj = Ext.decode(response.responseText);

p = obj;

},

callback : function(o,s,r)

{

}

});

}