PDA

View Full Version : i set timeout of a formpanel to 300 seconds, but it doesn't work. why?



sunrong
29 Nov 2010, 11:54 PM
my code below,


var fp = new Ext.FormPanel({
timeout: 300,
fileUpload: true,
width: 500,
frame: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 80,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [salarydate,
{ xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'chose file',
fieldLabel: 'EXCEL file',
name: 'excel_file',
buttonText: '',
buttonCfg: {iconCls: 'upload-icon'}
},
_grid
],
buttons: [{
text: 'OK',
handler: function(){
if(fp.getForm().isValid()){
console.time("test");
fp.getForm().submit({
url: 'index.php?model=user&action=in&',
params: {
type: 'basicsalary'
},
waitMsg: 'processing...',
success: function(fp, o){
console.timeEnd("test");
// _grid.store.loadData(o.result);
Ext.Msg.alert('info','success');


},
failure: function(fp, o){
console.timeEnd("test");
Ext.Msg.alert('warning', o.result.topics);
}
})
}
}
}
]
});
i set timeout to 300, butit still waits about 30 seconds and rises a syntax error ();

what's the problem?

thanks.

Condor
30 Nov 2010, 12:09 AM
A syntax error usually means that your server is returning the wrong information.

What is your server returning for the submit request?

sunrong
30 Nov 2010, 1:16 AM
function test(){
for($i = 1; $i< 400000000; $i++){

}

$errorMsg = 'Ddfksfkjsdf!';
echo "{success:true,msg:'" . $errorMsg . "'}";exit;
}

it takes more than 30 seconds to return a value.

and
if i change $i to half of 400000000 , it works correctly

Condor
30 Nov 2010, 1:35 AM
A formUpload doesn't use the timeout value (it can't be canceled anyway).

Are you sure this is not a problem on your server?

sunrong
30 Nov 2010, 5:59 AM
thanks Condor.

i upload a excel file , put it into grid , import it into mysql.



<script type="text/javascript" src="common/js/FileUploadField.js"></script>
<link rel="stylesheet" type="text/css" href="themes/default/css/file-upload.css"/>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var salarydate = new Ext.form.DateField({
label: 'month',
id:'salarydate',
name: 'salarydate',
value: new Date().dateFormat('Y-m'),
format: 'Y-m'
});

var _grid = new Ext.grid.GridPanel({
enableColumnMove :false,
border:false,
selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),
width: 480,
height: 385,
frame: true,
store:new Ext.data.Store({
autoLoad:true,
proxy: new Ext.data.HttpProxy({url:'default'}),
reader:new Ext.data.JsonReader({root: "topics",totalProperty: "totalCount"},
Ext.data.Record.create([
'username','name','gwgz','jdjt','zhbt','dqjt','zfbt', 'gdjxj','jnkk','bf',
'yanglbx','yilbx','sybx','zfgjj','ghh','dbyl','grsds','xzkk','bskjh','jjkk','bk'
])
)
}),
colModel: new Ext.grid.ColumnModel([
{header:"username", dataIndex:"username", align :"center", menuDisabled :true, width:50},
{header:"name", dataIndex:"name", align :"center", menuDisabled :true, width:70},
{header:"gwgz", dataIndex:"gwgz", align :"center", menuDisabled :true, width:50},
{header:"jdjt", dataIndex:"jdjt", align :"center", menuDisabled :true, width:50},
{header:"zhbt", dataIndex:"zhbt", align :"center", menuDisabled :true, width:50},
{header:"dqjt",dataIndex:"dqjt",align :"center", menuDisabled :true, width:50},
{header:"zfbt",dataIndex:"zfbt",align :"center", menuDisabled :true, width:50},
{header:"gdjxj", dataIndex:"gdjxj", align :"center", menuDisabled :true, width:100},
{header:"jnkk", dataIndex:"jnkk", align :"center", menuDisabled :true, width:50},
{header:"bf", dataIndex:"bf", align :"center", menuDisabled :true, width:50},
{header:"yanglbx",dataIndex:"yanglbx",align :"center", menuDisabled :true, width:50},
{header:"yilbx",dataIndex:"yilbx",align :"center", menuDisabled :true, width:50},
{header:"sybx", dataIndex:"sybx", align :"center", menuDisabled :true, width:50},
{header:"zfgjj", dataIndex:"zfgjj", align :"center", menuDisabled :true, width:50},
{header:"ghh", dataIndex:"ghh", align :"center", menuDisabled :true, width:50},
{header:"dbyl",dataIndex:"dbyl",align :"center", menuDisabled :true, width:50},
{header:"grsds",dataIndex:"grsds",align :"center", menuDisabled :true, width:50},
{header:"xzkk", dataIndex:"xzkk", align :"center", menuDisabled :true, width:50},
{header:"bsjkh", dataIndex:"bsjkh", align :"center", menuDisabled :true, width:50},
{header:"jjkk", dataIndex:"jjkk", align :"center", menuDisabled :true, width:50},
{header:"bk", dataIndex:"bk",align :"center", menuDisabled :true, width:50}
])
});

var fp = new Ext.FormPanel({
fileUpload: true,
timeout: 60000,
width: 500,
frame: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 80,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [salarydate,
{ xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'chose a EXCEL file',
fieldLabel: 'EXCEL file',
name: 'excel_file',
buttonText: '',
buttonCfg: {iconCls: 'upload-icon'}
},
_grid
],
buttons: [{
text: 'ok',
handler: function(){
if(fp.getForm().isValid()){
console.time("test");
fp.getForm().submit({
url: 'index.php?model=user&action=in&',
params: {
type: 'basicsalary'
},
waitMsg: 'processing...',
success: function(fp, o){
console.timeEnd("test");
// _grid.store.loadData(o.result);
Ext.Msg.alert('info','success');


},
failure: function(fp, o){
console.timeEnd("test");
Ext.Msg.alert('warning', 'failure');
}
})
}
}
}
]
});

fp.render(document.body);
loadend();
});
</script>



uploading file and putting it into grid both work ok,
but add 'imort' , syntax error emerges.
i can't figure out where is the problem, in extjs or mysql.

so i comment code about mysql , even about putting file into grid, just wait for more than 30 seconds


for($i = 1; $i< 400000000; $i++){ // waiting for more than 30 seconds

};
$errorMsg = 'error!';
echo "{success:true,msg:'" . $errorMsg . "'}";exit;


the same syntax error still rises.
syntax error () ext-all-debug.js (line 8273 )

8272 doDecode = function(json){
8273 return eval("(" + json + ')');
8274 },




i think formpanel timeout runs out, it got null and rise the problem . am i right ?

sunrong
5 Dec 2010, 10:55 PM
Condor , thanks! you are quite right!