Extjs 未定义EXT登录示例
我正在尝试使用ExtJS3.4.0实现简单的登录代码,为所有包含的文件提供了绝对路径,仍然面临Ext未定义错误。我正在使用firebug进行调试Extjs 未定义EXT登录示例,extjs,Extjs,我正在尝试使用ExtJS3.4.0实现简单的登录代码,为所有包含的文件提供了绝对路径,仍然面临Ext未定义错误。我正在使用firebug进行调试 <html> <head> <link rel="stylesheet" type="text/css" href="E:/SICSR/ext-3.4.0/ext-3.4.0/resources/css/ext-all.css"> <script type="text/javascript" src="E
<html>
<head>
<link rel="stylesheet" type="text/css" href="E:/SICSR/ext-3.4.0/ext-3.4.0/resources/css/ext-all.css">
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/ext-all.js"></script>
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/adapter/ext/ext-base.js"></script>
<SCRIPT TYPE="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
// Create a variable to hold our EXT Form Panel.
// Assign various config options as seen.
var login = new Ext.FormPanel({
labelWidth:80,
url:'login.asp',
frame:true,
title:'Please Login',
defaultType:'textfield',
monitorValid:true,
// Specific attributes for the text fields for username / password.
// The "name" attribute defines the name of variables sent to the server.
items:[{
fieldLabel:'Username',
name:'loginUsername',
allowBlank:false
},{
fieldLabel:'Password',
name:'loginPassword',
inputType:'password',
allowBlank:false
}],
// All the magic happens after the user clicks the button
buttons:[{
text:'Login',
formBind: true,
// Function that fires when user clicks the button
handler:function(){
login.getForm().submit({
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
// Functions that fire (success or failure) when the server responds.
// The one that executes is determined by the
// response that comes from login.asp as seen below. The server would
// actually respond with valid JSON,
// something like: response.write "{ success: true}" or
// response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}"
// depending on the logic contained within your server script.
// If a success occurs, the user is notified with an alert messagebox,
// and when they click "OK", they are redirected to whatever page
// you define as redirect.
success:function(){
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
if (btn == 'ok'){
var redirect = 'test.asp';
window.location = redirect;
}
});
},
// Failure function, see comment above re: success and failure.
// You can see here, if login fails, it throws a messagebox
// at the user telling him / her as much.
failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Login Failed!', obj.errors.reason);
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
login.getForm().reset();
}
});
}
}]
});
// This just creates a window to wrap the login form.
// The login object is passed to the items collection.
var win = new Ext.Window({
layout:'fit',
width:300,
height:150,
closable: false,
resizable: false,
plain: true,
border: false,
items: [login]
});
win.show();
});
</SCRIPT>
</head>
<body>
</body>
</html>
Ext.onReady(函数(){
Ext.QuickTips.init();
//创建一个变量来保存EXT表单面板。
//如图所示,分配各种配置选项。
var login=new Ext.FormPanel({
标签宽度:80,
url:'login.asp',
框架:对,
标题:'请登录',
defaultType:'textfield',
monitorValid:true,
//用户名/密码文本字段的特定属性。
//“name”属性定义发送到服务器的变量的名称。
项目:[{
fieldLabel:“用户名”,
名称:'loginUsername',
allowBlank:false
},{
fieldLabel:“密码”,
名称:'loginPassword',
输入类型:'password',
allowBlank:false
}],
//所有的魔法都发生在用户点击按钮之后
按钮:[{
文本:'Login',
是的,
//当用户单击按钮时激发的函数
处理程序:函数(){
login.getForm().submit({
方法:'POST',
waitTitle:“连接”,
waitMsg:“正在发送数据…”,
//当服务器响应时触发(成功或失败)的函数。
//执行的一个由
//来自login.asp的响应,如下所示。服务器将
//实际使用有效的JSON进行响应,
//类似于:response.write“{success:true}”或
//response.write“{success:false,errors:{reason:'登录失败。请重试。}”
//取决于服务器脚本中包含的逻辑。
//如果成功,用户将收到警报消息框的通知,
//当他们点击“确定”时,他们被重定向到任何页面
//您定义为重定向。
成功:函数(){
Ext.Msg.alert('Status','Login Successful!'),函数(btn,text){
如果(btn=='ok'){
var redirect='test.asp';
window.location=重定向;
}
});
},
//失败功能,请参见上面的注释:成功和失败。
//您可以在这里看到,如果登录失败,它会抛出一个messagebox
//在用户告诉他/她同样多的时候。
失败:函数(形式、动作){
如果(action.failureType=='server'){
obj=Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Login Failed!',obj.errors.reason);
}否则{
Ext.Msg.alert('Warning!','无法访问身份验证服务器:'+action.response.responseText);
}
login.getForm().reset();
}
});
}
}]
});
//这只是创建一个窗口来包装登录表单。
//登录对象被传递到items集合。
var win=新的外部窗口({
布局:'适合',
宽度:300,
身高:150,
可关闭:错误,
可调整大小:false,
朴素:没错,
边界:错,
项目:[登录]
});
win.show();
});
提前谢谢
Yuta Lolap 包含适配器的脚本标记首先出现:
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/ext-all.js"></script>
请参阅示例:并查看HTML源代码(而不是array grid.js的源代码),特别是第38-43行:
<!-- ** Javascript ** -->
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="../../ext-all.js"></script>