Sencha Touch 2으로 로그인 시스템을 만들고 있습니다. 양식을 제출하는 동안 문제가 발생합니다. 서버에서 응답 데이터를 가져 오지 않습니다.양식 제출이 작동하지 않습니다.
Ext.define("MyMobile.controller.LoginController", {
extend: "Ext.app.Controller",
views: ['LoginView'],
config: {
refs: {
loginForm: "#loginFormPanel"
},
control: {
'button[action=login]': {
tap: "authenticateUser"
}
}
},
authenticateUser: function (button) {
this.getLoginForm().submit({
url: 'login/authenticate',
method: 'POST',
success: function (form, result) {
debugger; //This block of code is not executing even after JSON response
var jsonoutput = Ext.decode(result); // json parsing
Ext.MessageBox.alert('Error', "Success");
},
failure: function (form, result) {//This block of code is not executing even after JSON response
Ext.MessageBox.alert('Error', "Invalid username/password");
}
});
}
});
보기
Ext.define("MyMobile.view.LoginView", {
extend: "Ext.form.FormPanel",
alias: "widget.mylogin",
id: 'loginFormPanel',
config: {
margin: '0 auto',
name: 'loginform',
frame: true,
url: 'login/Authenticate',
title: 'Login',
items: [
{
xtype: 'fieldset',
itemId: 'LoginFieldset',
margin: '10 auto 0 auto ',
title: '',
items: [
{
xtype: 'textfield',
label: 'User Name',
name: 'my-username',
required: true,
placeHolder: 'Username'
},
{
xtype: 'emailfield',
label: 'Email',
name: 'Email'
},
{
xtype: 'passwordfield',
label: 'Password',
name: 'my-password',
required: true,
placeHolder: 'Password'
}
]
},
{
xtype: 'button',
id: 'loginButton',
margin: '25 auto 0 auto ',
style: '',
maxWidth: 200,
ui: 'action',
width: '',
iconCls: 'user',
iconMask: true,
text: 'Login',
action: 'login'
}
]
}
});
App.JS
Ext.application({
name: "MyMobile",
appFolder: "myapp",
controllers: ["LoginController"],
views: ['LoginView'],
launch: function() {
var loginPanel= Ext.create('Ext.Panel', {
layout: 'fit',
items: [
{
xtype: 'mylogin'
}
]
});
Ext.Viewport.add(loginPanel);
}
});
수있는 몇 가지 중 하나 개를 기 : 다음은 내 코드
컨트롤러입니다 무엇이 문제인지 알아 내야합니까?
아래 JSON 응답은 서버에서 가져옵니다.
{ "사용자 이름": "무랄리", "isAdmin", "IsAuthenticated는"사실 : 사실}
는 는 심지어 JSON 200 확인 결과를받은 후, 기능을 제출 내 코드 형태 실패 콜백로 전환. 실패 콜백 함수 실패 : function (form, result) 결과 JSON으로 param을 얻고 있습니다. 그러나 그것이 왜 실패 했는가?
http://docs.sencha.com/touch/2-0/#!/api/Ext.form.Panel-method-submit했다 내 서버에서 JSON 응답. ", 결과를 얻거나 이것이 당신이 얻고 자하는 결과입니까? – Rob
JSON 응답과 200 OK 결과를 얻고 있습니다. 하지만 폼 제출의 성공 또는 실패 콜백이 실행되지 않습니다. –
흠 콜백을 사용하면 어떻게됩니까? function() {console.log ('cb'); }'?? – Rob