1. #1
    Ext User hiral's Avatar
    Join Date
    Jun 2008
    Posts
    52
    Vote Rating
    0
    hiral is on a distinguished road

      0  

    Lightbulb return value of ajax call

    return value of ajax call


    Hi All,

    I have one function which is used to validate IPv4 address. Let me know what will be the return value of this function.

    here as per my understanding if ipv4 address is not valid it will display me message but if it true then what it will do?

    What will be the return value of this function?

    Code:
    My call of this function is like
    ,saveIp(ipv4){
       
       if(ipv4 != ""){
              this.validateIPv4();
       }
    } // save Ip ends here
    
    
    // function for validating IPv4 address 
        ,validateIPv4:function(IPvalue){
            
            Ext.Ajax.request({
                url: script_path + 'managedevice/managedevice.php', 
                params: {
                   mode:"checkIpv4",
                   ipv4:IPvalue
                }, 
                success: function(response){
                  var o = Ext.decode(response.responseText);
                  alert(o.success);             
                  switch(o.success){
                      case true:  // Success                   
                          return;                                        
                      break;
                      case false:  // Fail    
                        Ext.MessageBox.alert('Error','Invalid Ipv4 address.');
                        return;                        
                      break;
                  }
                },
                failure: function(response){
                  var result=response.responseText;
                  Ext.MessageBox.alert('error','could not connect to the database. retry later');      
                }
             });    
                
        } // eof of validateIPv4
    Thanks
    Hiral

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    You can't do that. Ajax is asynchronous

  3. #3
    Ext User hiral's Avatar
    Join Date
    Jun 2008
    Posts
    52
    Vote Rating
    0
    hiral is on a distinguished road

      0  

    Lightbulb


    Hi Animal,

    Can you give some idea to do this?

    Is there any way that I can check something from server side and return like this way?

    Thanks
    hiral

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    It is possible to kludge Ajax to return synchronously. But not a good idea. See hendricd's Ajax UX.

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    The proper way it to chain events. Its always possible to do this, it just means unlearning a bit of ingrained procedural programming techniques and learning event driven techniques

Thread Participants: 2