1. #1
    Sencha Premium Member
    Join Date
    Jul 2009
    Location
    Poland
    Posts
    10
    Vote Rating
    0
    stricte is on a distinguished road

      0  

    Default Ajax.request factory

    Ajax.request factory


    Hi,

    i need help with my code. I want to build a Ajax.request factory, so:

    Code:
    MyApp.ajax_request = function(config){
    
       successfn = function(result, request){
           jsonData = Ext.util.JSON.decode(result.responseText);
           if(jsonData.success === true){
               config.successfn; //important. here i want to run function passed in config.
           }
           else{
             if(jsonData.error == 'TIMEOUT'){
                 Ext.Msg.show({
                     title: 'Błąd - ' + jsonData.error,
                     msg: jsonData.msg,
                     buttons: Ext.MessageBox.OK,
                     fn: function(){ window.location = '/' }
                 });
             }
             else if(jsonData.error == 'NOT_LOGGED'){
                 Ext.Msg.show({
                     title: 'Błąd - ' + jsonData.error,
                     msg: jsonData.msg,
                     buttons: Ext.MessageBox.OK,
                     fn: function(){ window.location = '/' }
                 });
             }
             else{
                 Ext.Msg.alert('Błąd - ' + jsonData.error, jsonData.msg);
             }
           }
       }
    
      failurefn = function(result, request){
           Ext.Msg.alert('error', 'error msg');
       }
    
    
      Ext.Ajax.request({
          url: config.url,
          params: config.params,
          success: successfn,
          failure: failurefn
      });
    }
    As I mentioned, I want to pass in config function which will be fired in success callback:

    Code:
    config = {
                   url: '/operators/new',
                   successfn: function(){
                      //some code to run, but never will. why?
                   },
                   params: {data: Ext.encode(nops)}
                 };
    MyApp.ajax_request(config);
    My question is how to pass function which will be trigered as is in my Ajax.request?
    -->

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default Just do it!

    Just do it!


    Code:
     if(jsonData && jsonData.success === true){
          if(Ext.isFunction( config.successfn )){
              config.successfn(jsonData); //important. here i want to run function passed in config.
         }
     }
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.

    -->

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi