PDA

View Full Version : Submit form TypeError problem



vicvolk
16 Feb 2013, 10:37 AM
Hello! Please help, if you can.
I have a form with a file field. When I submit it, I see in Firefox an error: "TypeError: a is undefined ext-all.js:27". Because of this error I'm unable to close the window with that form. The code is:




var win = Ext.create('Ext.window.Window',{
title:'Path',
modal:true,
closable: true,
closeAction:'destroy',
width:312,
height:176,
fullscreen:true,
layout:'border',
draggable:true,
resizable:true,
constrainHeader:true,
id:'iconpath',
items:[{
region:'center',
border:0,
bodyStyle:'padding:4px',
layout:'fit',
autoScroll:true,
anchor:'100%',
width:'100%',
xtype:'form',
items: [{
xtype:'filefield',
name:'icon',
allowBlank: false,
anchor:'100%',
width:'100%',
buttonText:'????...',
regex:/(.)+((\.png)|(\.jpg)|(\.gif)(\w)?)$/i
}],
buttons: [{
text:'OK',
handler:function(){
var form = this.up('form').getForm()
if(form.isValid()){
form.submit({
url:'uploader.php',
success:function(fp,o){
Ext.Msg.alert('Success', 'Your photo has been uploaded.')
}
})
}
}
},{
text: '???????',
handler: function(){
win.destroy()
}
}]
}]
}).show()



Many thanks!
Victor.

PS. I use extjs-4.1.1a

vicvolk
16 Feb 2013, 11:20 AM
Example from the "Example Usage" section - http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.File - also throws the same error in extjs-4.1.1a. I guess it should be considered as bug.

vicvolk
16 Feb 2013, 11:26 AM
Full and simple test-case which throws error in extjs-4.1.1a




Ext.onReady(function(){

Ext.create('Ext.form.Panel', {
title: 'Upload a Photo',
width: 400,
bodyPadding: 10,
frame: true,
renderTo: Ext.getBody(),
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
}],
buttons: [{
text: 'Upload',
handler: function() {
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'uploader.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o) {
Ext.Msg.alert('Success', 'Your photo has been uploaded.');
}
})
}
}
}]
})

})




The example was taken from documentation. I wonder if there is a way to solve this problem?

fabioricali
20 Apr 2013, 10:06 AM
I have same problem.... :(

lichunyu@vip.qq.com
4 Jul 2013, 11:54 PM
Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.