我有一个J2EE Web应用程序,其中包含一个表单,我将文件上传到服务器上的某个位置.在上传期间,向用户显示waitMsg,一旦上传完成,msgBox指示相同,就会消失.成功案例的代码也在js文件中提供.但是上传工作正常,但即使在服务器上传完成后,waitMsg仍会继续.
给出了js代码:
Ext.onReady(function(){
Ext.QuickTips.init();
var msg = function(title, msg){
Ext.Msg.show({
title: title,
msg: msg,
minWidth: 200,
modal: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
};
var fp = new Ext.FormPanel({
renderTo: 'fi-form',
fileUpload: true,
width: 500,
frame: true,
title: 'Upload XML Config File ',
autoHeight: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Select the xml File to upload',
fieldLabel: 'File',
name: 'file',
buttonCfg: {
text: '',
iconCls: 'upload-icon'
}
}],
buttons: [{
text: 'Upload',
handler: function(){
if(fp.getForm().isValid()){
fp.getForm().submit({
url: 'uploadXML.htm',
waitMsg: 'Uploading your xml file...',
success: function(fp, o){
msg('Success', 'Processed file "'+o.result.file+'" on the server');
}
});
}
if (!validateFileExtension(Ext.getDom('form-file').value)) {
Ext.MessageBox.alert('Select another file',
'Only XML file, please.');
return;
}
}
},{
text: 'Reset',
handler: function(){
fp.getForm().reset();
}
}]
});
function validateFileExtension(fileName) {
var exp = /^.*\.(xml|XML)$/;
return exp.test(fileName);
}
});
Run Code Online (Sandbox Code Playgroud)
不确定我错过了什么.
提前致谢.
Dai*_*Bok 10
有类似的问题.发现您需要在处理文件上载的页面上将内容类型设置为"text/html".:-(
Response.ContentType = "text/html";
Run Code Online (Sandbox Code Playgroud)
如果您阅读Ext.data.Connection的文档,您将看到
浏览器解析服务器响应以创建IFRAME的文档.如果服务器使用JSON发送返回对象,则必须将Content-Type标头设置为"text/html",以告知浏览器将文本未更改地插入到文档正文中.
花了一些时间来找到这个,但是当我遇到你的问题时,别人可能会遇到类似的问题!
希望这会对他们有所帮助!
| 归档时间: |
|
| 查看次数: |
5100 次 |
| 最近记录: |