Results 1 to 3 of 3

Thread: Help

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    28

    Default Help

    ??? ????????? ??????? ????????? ?????????? ??????

    Code:
    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;
    };

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    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():

    Code:
    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 {
        // ...
      }
    });

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    28

    Default thanks

    THanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •