主要只有两个页面 一个是login.jsp 一个是query.jsp(手动加入数据) 两个页面单独运行没有问题
login.jsp嵌入的js
Ext.onReady(function(){
Ext.QuickTips.init();
var simple = new Ext.FormPanel({
labelWidth: 75, // label settings here cascade unless overridden
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],
buttons: [{
text: '提交',
handler:function(){
simple.getForm().submit({url:'test!login',waitMsg:'Login ing'})
}
},{
text: '重置',
handler:function(){
simple.form.reset();
}
}]
});
simple.render(document.body)
});
query.jsp 的js
Ext.onReady(
function(){
//创建测试数据
var testData=[
['Apple',30.0,0.24,0.9,'9/1 12:00am'],
['hp',30.0,0.24,0.9,'9/1 12:00am'],
['lennovo',30.0,0.24,0.9,'9/1 12:00am']
];
//创建数据store
var store=new Ext.data.ArrayStore({
fields:[
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'},
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
});
//读取测试数据
store.loadData(testData);
//创建Grid
//加载store
//规定列属性
var grid=new Ext.grid.GridPanel({
store:store,
columns: [
{
id :'company',
header : 'Company',
width : 160,
sortable : true,
dataIndex: 'company'
},
{
header : 'Price',
width : 75,
sortable : true,
dataIndex: 'price'
},
{
header : 'Change',
width : 75,
sortable : true,
dataIndex: 'change'
},
{
header : '% Change',
width : 75,
sortable : true,
dataIndex: 'pctChange'
},
{
header : 'Last Updated',
width : 85,
sortable : true,
renderer : Ext.util.Format.dateRenderer('m/d/Y'),
dataIndex: 'lastChange'
}
],
stripeRows: true,
autoExpandColumn: 'company',
height: 350,
width: 600,
title: 'Array Grid'
});
grid.render('aaa');
});
只要一跳转 就会出现
syntax error
simple.getForm().submit 是使用ajax提交。后台如果返回query.jsp
ajax提交会获取query.jsp的内容并转换成json数据。所以出现问题。
你后台ajax应该返回 json数据通过window.localhost.href来跳转
例如:通过 success 回调函数跳转
action 需要返回json数据 {success:true} success true 表示成功 false失败。而不是跳转界面
[code="java"]simple.getForm().submit({
url:'test!login',
waitMsg:'Login ing',
success:function(response,options){ //成功执行回调函数
window.localhost.href="";//需要跳转的页面
}
})[/code]