2013-10-31 100 views
1

我的控制器使用的Ajax.Request無法在煎茶

Ext.define('MyApp.controller.login', { 
    extend: 'Ext.app.Controller', 
    requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'], 
    config: { 
     refs: { 
      loginButton : ' login #logInButton', 
      loginform : 'login #loginform' 
     }, 
     control: { 
      loginButton:{ 
       tap: 'loginButton' 
      } 
     } 
    }, 
    //functions 
    loginButton: function(){ 
     Ext.Msg.alert('Logged In'); 

     Ext.Ajax.request({ 
      url: getLogonUrl(), 
      method: 'POST', 
      params: { 
       username: Ext.getCmp('username').getValue(), 
       password: Ext.getCmp('password').getValue(), 
      }, 
      success: function (response) { 
       Ext.Msg.alert('Logged In'); 

       var result = Ext.JSON.decode(response.responseText); 
       console.log(resultResponse.Texts); 
       if (result.success === "true") 
        Ext.Msg.alert('Logged In'); 
       else 
        Ext.Msg.alert('Not Logged In'); 
      }, 
     }); 
    } 
}); 

我鑑於登錄

Ext.define('MyApp.view.login', { 
    extend: 'Ext.form.Panel', 
    alias: "widget.loginview", 
    xtype: 'login', 
    requires: [ 
     'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button', 
     'Ext.field.Password','Ext.field.Hidden', 'Ext.Img' 
    ], 
    config:{ 
     id: 'loginform', 
     iconCls: 'user', 
     title: 'Login', 
     styleHtmlCls: true, 
     styleHtmlContent: true, 
     scrollable: null, 
     items: [ 
      {  
       xtype: 'image', 
       src:'app/view/img/airitlogo.png', 
       height: 200, 
       style:{ top: '100px'}, 
      }, 
      { 
       xtype: 'fieldset', 
       width: 1500, 
       height: 200, 
       style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'} 
       cls: 'login', 
       title: '<div id="title">PROPworks - Meter Sign In</div>', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'Activation failed', 
         itemId: 'failLogin', 
         hidden: true, 
         hideAnimation: 'fadeOut', 
         showAnimation: 'fadeIn', 
         style: 'background: yellow; margin: 5px, 0px', 
        }, 
        { 
         xtype: 'textfield', 
         placeHolder: 'Username', 
         Id: 'username', 
         name : 'usernameTextField', 
         style: 'height: 60px', 
        }, 
        { 
         xtype: 'passwordfield', 
         placeHolder: 'Password', 
         Id: 'password', 
         name : 'passwordTextField', 
         style: 'height: 60px', 
        } 
       ]//second item list 
      }, 
      { 
       xtype: 'button', 
       itemId: 'logInButton', 
       text: 'Log In', 
       ui:  'confirm', 
       cls: 'button', 
       width: 1500, 
       style: ' margin: 15px 0px 0px 200px; height: 70px', 
      },   
     ]//first item list 
    } 
}); 

一個Ext.msg.alert(),不能正常工作,一旦它過去的Ajax.Request,我的網址是從我的HTML文件頭導入的文件調用的函數

<!DOCTYPE HTML> 
<html manifest="" lang="en-US"> 
<head> 
    <meta charset="UTF-8"> 

    <script type="text/javascript" src="js/pwmain-ui.js"></script> 
    <script type="text/javascript" src="js/jquery.min.js"> </script> 
    <script type="text/javascript" src="js/jquery-ui.js"> </script> 
    <script type="text/javascript" src="js/jsonselect.min.js"> </script>  
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script> 
    <script type="text/javascript" src="js/jquery.atmosphere.js"> </script> 
    <title>MyApp</title> 

回答

2

你的代碼中有很多不必要的,可以打破sencha。

也許我錯了,但不應該在關閉}]括號之前放置,

我試圖清理這些。這些可以很容易地打破煎茶。至少我在這些事情上遇到了很多問題。

Ext.define('MyApp.controller.login', { 
    extend: 'Ext.app.Controller', 
    requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'], 
    config: { 
     refs: { 
      loginButton : ' login #logInButton', 
      loginform : 'login #loginform' 
     }, 
     control: { 
      loginButton:{ 
       tap: 'loginButton' 
      } 
     } 
    }, 
    //functions 
    loginButton: function(){ 
     Ext.Msg.alert('Logged In'); 

     Ext.Ajax.request({ 
      url: getLogonUrl(), 
      method: 'POST', 
      params: { 
       username: Ext.getCmp('username').getValue(), 
       password: Ext.getCmp('password').getValue() 
      }, 
      success: function (response) { 
       Ext.Msg.alert('Logged In'); 

       var result = Ext.JSON.decode(response.responseText); 
       console.log(resultResponse.Texts); 
       if (result.success === "true") 
        Ext.Msg.alert('Logged In'); 
       else 
        Ext.Msg.alert('Not Logged In'); 
      } 
     }); 
    } 
}); 

登錄鑑於:

Ext.define('MyApp.view.login', { 
    extend: 'Ext.form.Panel', 
    alias: "widget.loginview", 
    xtype: 'login', 
    requires: [ 
     'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button', 
     'Ext.field.Password','Ext.field.Hidden', 'Ext.Img' 
    ], 
    config:{ 
     id: 'loginform', 
     iconCls: 'user', 
     title: 'Login', 
     styleHtmlCls: true, 
     styleHtmlContent: true, 
     scrollable: null, 
     items: [ 
      {  
       xtype: 'image', 
       src:'app/view/img/airitlogo.png', 
       height: 200, 
       style:{ top: '100px'} 
      }, 
      { 
       xtype: 'fieldset', 
       width: 1500, 
       height: 200, 
       style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'} 
       cls: 'login', 
       title: '<div id="title">PROPworks - Meter Sign In</div>', 
       items: [ 
        { 
         xtype: 'label', 
         html: 'Activation failed', 
         itemId: 'failLogin', 
         hidden: true, 
         hideAnimation: 'fadeOut', 
         showAnimation: 'fadeIn', 
         style: 'background: yellow; margin: 5px, 0px' 
        }, 
        { 
         xtype: 'textfield', 
         placeHolder: 'Username', 
         Id: 'username', 
         name : 'usernameTextField', 
         style: 'height: 60px' 
        }, 
        { 
         xtype: 'passwordfield', 
         placeHolder: 'Password', 
         Id: 'password', 
         name : 'passwordTextField', 
         style: 'height: 60px' 
        } 
       ]//second item list 
      }, 
      { 
       xtype: 'button', 
       itemId: 'logInButton', 
       text: 'Log In', 
       ui:  'confirm', 
       cls: 'button', 
       width: 1500, 
       style: 'margin: 15px 0px 0px 200px; height: 70px' 
      }   
     ]//first item list 
    } 
});