ExtJS 4 MVC アーキテクチャ スタイルのログイン フォームがあります。つまり、1 つのコントローラーと 1 つのビューがあります。
ビュー ファイル (コンポーネント作成部分のみが表示されます):
initComponent: function() {
this.items = [
{border:false, baseCls: 'x-plain', flex:8}, // 13/8 - is golden ratio (approx.)
{
border: false,
baseCls: 'x-plain',
layout: {
type: 'vbox',
pack: 'center',
align: 'center'
},
items: [
{
xtype: 'form',
url: 'http://localhost/my_site/login.php',
title: 'login_form_title',
bodyPadding: 5,
width: 280,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 90,
anchor: '100%'
},
items: [
{
xtype: 'textfield',
name: 'username',
fieldLabel: 'username',
allowBlank: false
},
{
xtype: 'textfield',
inputType: 'password',
name: 'password',
fieldLabel: 'password',
allowBlank: false
},
{
border: false,
baseCls: 'x-plain',
layout: {
type: 'hbox',
pack: 'center',
align: 'center'
},
items: [
{
xtype: 'button',
formBind: true,
disabled: true,
text: 'login',
action: 'login'
}
]
}
]
}
]
},
{border:false, baseCls: 'x-plain', flex:13} // 13/8 - is golden ratio (approx.)
];
this.callParent(arguments);
}
私のコントローラーでは、ログインボタンのonclickをいくつかの関数にバインドし、その関数内で次のコードを使用してフォームをサーバーに送信しています。
oForm.submit({
success: function(form, action) {
console.log('success');
},
failure: function(form, action) {
console.log(action.failureType);
}
});
そしてこれはhttp://localhost/my_site/login.php
<?php
exit;
ログインボタンを押すとsuccess
、開発者コンソールに表示されます。質問は次のとおりです。
- 空の応答を と見なすこと、つまり、その場合に
failure
開発者コンソールにログを記録させることは可能ですか?failureType
- 空の応答が と見なされるのはなぜ
success
ですか? 公式ドキュメントや他のリソースへのリンクは大歓迎です。
以下を使用するhttp://localhost/my_site/login.php
とserver
、正しい開発者コンソールが表示されます。
<?php
echo json_encode(
array(
'success'=>false,
'errors' => array(
'reason' => 'Invalid username or password'
)
)
);
exit;