今天搞了个登陆框,但是在登陆的时候一直出现等待窗体,又找不出什么原因。用FireBug检验的时候发现数据已经成功POST,但是貌似一直获取不到返回值。卡在waitMsg数据处,死循环。FireBug检查的结果是SYNTAX ERROR : ExtJS制作Form
Ext.onReady(function() {
Ext.QuickTips.init();
var Login = new Ext.form.FormPanel({
labelWidth : 70,
labelAlign : 'right',
frame : true,
title : 'Site Manage System',
bodyStyle : 'padding:5px 5px 0',
width : 350,
defaults : {width: 150, msgTarget: 'side'},
defaultType: 'textfield',
items: [{
fieldLabel: 'Username',
name : 'username',
allowBlank: false,
blankText : 'Please input your username'
}, {
fieldLabel: 'Password',
inputType : 'password',
name : 'password',
allowBlank: false,
blankText : 'Please input your password'
}],
buttons: [{
text: 'Login',
formBind: true,
type: 'submit',
handler: function (){
if (Login.getForm().isValid()) {
Login.getForm().submit({
clientValidation: true,
waitTitle: 'Waiting',
waitMsg: 'Check Login Information...',
method:'POST',
url:'login.php?action=login',
success:function(form,action){
if (action.result.msg == 'OK') {
document.location = 'admincp.php';
} else {
Ext.Msg.alert('Status',action.result.msg);
}
},
failure:function(){
Ext.Msg.alert('Status','System Error!');
}
});
}
}
},{
text: 'Cancel',
handler: function() {Login.form.reset();}
}]
});
Login.render(Ext.get('loginForm'));
});
PHP文件
if ($_GET['action'] == 'login') {
$username = $_POST['username'];
$password = $_POST['password'];
if ($db->GetLogin($username, $password)){
echo "{success:true,msg:'OK'}";
exit();
} else {
echo "{success:true,msg:'Wrong user name or password.'}";exit();
}
}