Extタイミング送信要求



 
/***********************
    Ext      
***********************/
// JavaScript Document var task_CheckLoginState;
//       
Ext.onReady(
   function(){ 
       task_CheckLoginState = { 
           run: checkLogin,//           
           interval: 10000//    ,     ,   10  
       } 
       Ext.TaskMgr.start(task_CheckLoginState);//          
});   

function showlogin() { //       }   //          

function checkLogin(){ 
     Ext.Ajax.request({ 
         url: 'login.php',//            
         disableCaching: true,//      ,      
         timeout: 10000,//      ,         
         success: function(response, option){//ajax          
            if (!response || response.responseText == '') {
                 //       ,          
                 Ext.TaskMgr.stop(task_CheckLoginState); 
                 Ext.MessageBox.show({ 
                      title: '  ', 
                      msg: '              ,         。', 
                      buttons: Ext.Msg.OK, 
                      icon: Ext.MessageBox.ERROR, 
                      fn: function(btn, text){ 
                          if (btn == 'ok') { 
                              showlogin();//       
                          } 
                      } 
                 }); 
                 return; 
             } else { 
                 result = Ext.decode(response.responseText); 
                 if (result.success == 'true') {//success ext      url        
                        if (result.state == 'true') {//state        ,             
                               return true; 
                        } else {//       
                             Ext.TaskMgr.stop(task_CheckLoginState); 
                             Ext.MessageBox.show({ 
                                   title: '    ', 
                                   msg: '                ,     。', 
                                   buttons: Ext.Msg.OK, 
                                   icon: Ext.MessageBox.INFO, 
                                   fn: function(btn, text){ 
                                       if (btn == 'ok') { showlogin(); } //      
                                   } 
                              }); 
                              return false; 
                        } 
                  } else {//success       true,         
                  Ext.TaskMgr.stop(task_CheckLoginState); 
                  Ext.MessageBox.show({ 
                         title: '  ', 
                         msg: '                ,                 。', 
                         buttons: Ext.Msg.OK, 
                         icon: Ext.MessageBox.ERROR, 
                         fn: function(btn, text){ 
                             if (btn == 'ok') { showlogin(); } //      
                         } 
                  }); 
             } 
          } 
       }, 
       failure: function(data){//ajax          
             Ext.TaskMgr.stop(task_CheckLoginState); 
       }
     });
}