PDA

View Full Version : Help



pav-pas
10 May 2011, 9:16 PM
??? ????????? ??????? ????????? ?????????? ??????


function FinDat7D(){
var result = false;
Ext.Ajax.request({
url: 'php/method/setting.php?par=DateNow',
callback: function(options, success, resp){
if(success){
var o = Ext.decode(resp.responseText);
if(o.success){
result = true; //?? ??????????
}
}
}
});
return result;
};

fay
11 May 2011, 2:21 AM
Though i don't understand russian - i think that's the language?! - you're missing the point of the Asynchronous part of AJAX: this function will always return false because the request will not have completed by the time the function returns. You need to change your thinking here and adjust how you use FinDat7D():



function FinDat7D(callbackFunc)
{
Ext.Ajax.request({
url: 'php/method/setting.php?par=DateNow',
callback: function(options, success, resp)
{
if(success)
{
var o = Ext.decode(resp.responseText);
callbackFunc(o.success);
}
else
{
callbackFunc(false);
}
}
});
};

// so instead of: if (FinDat7D() == true) { ... } you need to re-write your logic with:

FinDat7D(function(success)
{
if (success) {
// ...
}
else {
// ...
}
});

pav-pas
11 May 2011, 3:36 AM
THanks =D>