PDA

View Full Version : unexpected end of xml on form submit.



DavidSingleton
21 Sep 2009, 11:19 AM
Hey guys, having an issue. I'm doing this exact same thing in numerous places, but I can't seem to get it to work here. I believe the issue is with one of my form fields, but i'm not sure. The form renders fine, no issues there, but when i click submit i get unexpected end of xml source ")". It brings up my wait msg but it never kicks off the save url. Any suggestions?



items: [{
xtype: 'hidden',
name: 'id',
fieldLabel: 'id'
},{
xtype: 'textfield',
fieldLabel: 'Item Name',
name: 'item_name',
allowBlank:false
}, new Ext.form.ComboBox({
transform: 'catagory',
triggerAction: 'all',
fieldLabel: 'Catagory',
name: 'catagory',
lazyRender: true,
typeAhead: true,
allowBlank: true,
forceSelection: false
}),{
xtype: 'textarea',
fieldLabel: 'Item Description',
name: 'item_desc',
allowBlank:true
}, new Ext.form.ComboBox({
transform: 'room_id',
triggerAction: 'all',
fieldLabel: 'Room',
name: 'room_id',
lazyRender: true,
typeAhead: true,
allowBlank: false,
forceSelection: true
}), new Ext.form.ComboBox({
fieldLabel: "Has DataDot",
allowBlank: false,
transform: 'datadot',
triggerAction: 'all',
lazyRender: true,
typeAhead: true,
forceSelection:true
}), new Ext.form.DateField({
fieldLabel: "Purchase Date",
allowBlank: false,
name: "purchase_date",
format: "Y-m-d"
}), {
xtype: 'textfield',
fieldLabel: "Purchased From",
allowBlank: true,
name: "purchased_from"
}, {
xtype: "numberfield",
fieldLabel: "Warranty Months",
allowBlank: true,
name: "warranty_months",
allowDecimals: false
}, {
xtype: "numberfield",
fieldLabel: "Purchase Price",
allowBlank: true,
name: "purchase_price",
allowDecimals: true
}],
buttons: [{
text: 'Save',
handler: function(){
if(Ext.getCmp('item-form').getForm().isValid()){
Ext.getCmp('item-form').getForm().submit({
url: '../HIM/JsonData/Item_Update.php',
waitMsg: 'Updating your item!',
success: function(fp, o){
Itemmsg('Success', 'Item updated!');
reloadItemData();
},
failure: function(fp, o) {
Itemmsg('Failure', 'There was an error updating your item, if the problem continues please contact support!');
}
});
}
}

},{
text: 'Reset',
handler: function(){
Ext.getCmp('item-form').getForm().reset();
}

}]
}]} );

tubamanu
21 Sep 2009, 1:47 PM
did your data get transefered correct to your php script ?

when using form submit, u need to send a success response from your server....maybe this helps....

DavidSingleton
21 Sep 2009, 3:28 PM
Nah, the error kicks before the data even starts going to my php script. It's something wrong in the ext. Just can't figure out what.

DavidSingleton
22 Sep 2009, 5:37 AM
bump, any other suggestions?

Condor
22 Sep 2009, 5:59 AM
Did you set fileUpload:true or use enctype="multipart/form-data"?

In that case your server response has to conform to specific rules (read this (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.BasicForm)).

DavidSingleton
29 Sep 2009, 5:33 PM
I understand that, but the form is not ever hitting my submit page. Its erroring out on .getForm(); I just can't figure out why. And i'm not uploading any files, its just a simple form.

DavidSingleton
30 Sep 2009, 5:44 AM
So, its strange, I have the same code running on the selection model and it works, but when i submit the form, thats when things go haywire. Although it never submits. It dies when you do: Ext.getCmp('formname').getForm().isValid(); If you take that out it dies at .getForm().submit.

I'm including the whole form code. I was trying to avoid this because i know it's a lot to read, but i'm really stumped here.



Ext.form.Field.prototype.msgTarget = 'side';

var itemdata = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '../HIM/JsonData/Item_Data.php'
}),
remoteSort: false,
reader: new Ext.data.JsonReader({
root: "results",
totalProperty: "total",
id: "id"
},[
{name: "id", type: "int"},
{name: "userid", type: "int"},
{name: "item_name", type: "string"},
{name: "item_desc", type: "string"},
{name: "room_id", type: "int"},
{name: "datadot", type: "int"},
{name: "purchase_date"},
{name: "purchase_price", type: "float"},
{name: "purchased_from", type: "string"},
{name: "warranty_months", type: "int"},
{name: "warranty_exp_date", type: "date"},
{name: "catagory", type: "string"}

])});
var loaditemStore = function() {
itemdata.load();
};
var getColumnModel = function(){
var itemcm = new Ext.grid.ColumnModel([
{align: 'left', dataIndex: 'item_name', header: 'Name', width: 100, sortable: true},
{align: 'left', dataIndex: 'item_desc', header: 'Description', width: 200, sortable: true},
{align: 'right', dataIndex: 'purchase_price', header: 'Purchase Price', width: 100, sortable: true, renderer: Ext.util.Format.usMoney}
]);
this.filters = new Ext.ux.grid.GridFilters({
local:true,
filters:[
{dataIndex: "item_name", type: "string"},
{dataIndex: "item_desc", type: "string"},
{dataIndex: "purchase_price", type: "numeric"}
]
});
return itemcm;
}

var itemgridForm = new Ext.FormPanel({
id: 'item-form',
frame: true,
labelAlign: 'left',
title: 'Item Data',
bodyStyle: 'padding:5px',
width: 750,
fileUpload: true,
layout: 'column',
items: [{
columnWidth: 0.60,
layout: 'fit',
items: {
xtype: 'grid',
id: 'itemgrid',
ds: itemdata,
cm: getColumnModel(),
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
Ext.getCmp("item-form").getForm().loadRecord(rec);
console.log(rec);
var grid = Ext.getCmp('itemgrid');
var selections = grid.getSelectionModel().getSelections();
for(var i = 0; i < selections.length; i++) {
var x = selections[i].get('id');
// do something
}
var mgr = Ext.getCmp('infopane').getUpdater();
mgr.update({
url: '../HIM/itemimage_viewer.php',
params: {
itemid: x
}
});
}
}
}),
plugins: [this.filters],
tbar: [{
text: 'Add Item',
tooltip: 'Add a room!',
iconCls: 'add',
handler: additemwindow
}, '-', {
text: 'Delete Item',
tooltip: 'Remove a room!',
iconCls: 'remove',
handler: handleDeleteItem
}, '-', {
text: 'Add Picture',
tooltip: 'Add an Image to this room',
iconCls: 'picture',
handler: addItemImages
}, '-', {
},'->', {
text: 'Refresh',
tooltip: 'Click to Refresh the table',
handler: reloadItemData,
iconCls:'refresh'
}],
height: 400,
title:'Item Data',
border: true,
listeners: {
render: function(g) {
g.getSelectionModel().selectRow(0);
},
delay: 10 // Allow rows to be rendered.
}
}
},{
columnWidth: 0.4,
xtype: 'fieldset',
labelWidth: 90,
title:'Room details',
defaults: {width: 140, border:false}, // Default config options for child items
defaultType: 'textfield',
autoHeight: true,
bodyStyle: Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;',
border: false,
style: {
"margin-left": "10px", // when you add custom margin in IE 6...
"margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0" // you have to adjust for it somewhere else
},
items: [{
fieldLabel: 'Purchased From',
allowBlank: true,
name: 'item_name',
id: 'itemname',
}],
buttons: [{
text: 'Save',
handler: function(){
if(Ext.getCmp("item-form").getForm().isValid()) {
Ext.getCmp("item-form").getForm().submit({
url: '../HIM/JsonData/Item_Update.php',
waitMsg: 'Updating your item!',
success: function(fp, o){
Itemmsg('Success', 'Item updated!');
reloadItemData();
},
failure: function(fp, o) {
Itemmsg('Failure', 'There was an error updating your item, if the problem continues please contact support!');
}
});
}
else {
Itemmsg('form not valid', 'Your form is not valid');
}

}
}]
}]});
loaditemStore();
itemgridForm.render('item-manage');


I've taken out every form field except for one in hopes that there was something wrong with one of them. Alas, that is not the case, i still get the same message even with just one form field.

GustavR
14 Jan 2010, 1:50 PM
I've came across the exactly same problem. Have you found some solution or any clue that could help since then?

Thank you!

DavidSingleton
14 Jan 2010, 1:52 PM
Yeah I was a big dork. I had used code from an example i found here on the site and it had this in it:

fileUpload: true,

Once i took that out, all was well again.

GustavR
14 Jan 2010, 2:26 PM
Argh... great.
Because I DO use fileUpload: true, because I have one. Still it is the same problem: On some filetypes it doesn't even submit the form to the sever, bails out before.
*.csv files work great, but *.dbf files for example don't.

Any other suggestions, anyone?
Didn't had this problem on extjs2, upgraded (to ext3) and now get this error whits dbf-files.

Thanks so far

Condor
14 Jan 2010, 11:54 PM
This problem is not related to the file you upload, but to the response from your server.

What does your server return when you upload the .dbf file?

GustavR
15 Jan 2010, 2:21 AM
Argh... I'm dumb! I always searched for the Ajax-Request in my Firebug, but on fileuploads there isn't one!
I naturally know that, but this time there was a lock in my brain.
Sorry for asking such silly questions, the problem of course lied at the answer of my php-script and not in extjs.

Thanks for opening my eyes!

tubamanu
15 Jan 2010, 4:18 AM
how does your serverresult look like ?

i'm having some trouble with the serverresponse. i'm using symfony framework my response looks like this:



$this->renderText('{"success":true}');


it works fine if do not use fileUpload: true....


my error message is unexpected end of xml......

Condor
15 Jan 2010, 4:23 AM
The response for a fileUpload needs to be HTML.

This means that you have to set the Content-type to text/html and return something like:

<html><body><textarea>{success: true}</textarea></body></html>

(it also works without the <textarea>, but in that case you need to HTML-escape the JSON data)

tubamanu
15 Jan 2010, 5:29 AM
yeah thx!
but this only works great Firefox, in IE6+ it is not working.........:(

Condor
15 Jan 2010, 5:47 AM
What's your server response (header + data)?

tubamanu
15 Jan 2010, 7:12 AM
i solved it, i forgot to change the header of my response....
thx 4 your help condor :)