PDA

View Full Version : Multi Part Form Upload / Ajax



bsmithinghamisd
14 Oct 2012, 5:38 PM
I have a multipart form that uploads via Ajax, the upload seems to work fine, however when the callback comes to redirect the page, it doesn't redirect, it's just spinning. I see other people have similar issues, but no concrete answer. Hopefully, someone might be able to help.

Thanks in advance.



<script type="text/javascript">






Ext.require([
'Ext.form.*',
'Ext.data.*'
]);


Ext.onReady(function(){

//Models
Ext.define('BidDoc', {
extend: 'Ext.data.Model',
fields: [
'biddocID',
'bidID',
'biddocTitle',
'biddocDescription',
'biddocOrder',
'biddocPostedDate',
'biddocPostedDate_DATE',
'biddocPostedDate_TIME',
'biddocDueDate_DATE',
'biddocDueDate_TIME',
'biddocSubmitHardCopyFlag',
'biddocSubmitUploadFlag',
'biddocSubmitNoneFlag',
'biddocOriginalFileName',
'biddocNotes',
'bidDocType_catalogitemID',
'biddocSealedFlag'
]
});
Ext.define('example.fielderror', {
extend: 'Ext.data.Model',
fields: ['id', 'msg']
});
Ext.define('Bid', {
extend: 'Ext.data.Model',
fields: [
'bidID',
'bidTitle',
'bidDescription',


'bidProfileDeadlineDate_DATE',
'bidProfileDeadlineDate_TIME',


'bidOpeningDate_DATE',
'bidOpeningDate_TIME',


'bidQuestionDeadlineDate_DATE',
'bidQuestionDeadlineDate_TIME',


'bidIssueDate_DATE',
'bidIssueDate_TIME',


'bidEstAwardRecommendationDate_DATE',
'bidEstAwardRecommendationDate_TIME',


'bidEstContractStartDate_DATE',
'bidEstContractStartDate_TIME',


'bidResponseFormsDeadlineDate_DATE',
'bidResponseFormsDeadlineDate_TIME',


'bidFinalResponseFormsPostedDate_DATE',
'bidFinalResponseFormsPostedDate_TIME',


'bidEstContractEndDate_DATE',
'bidEstContractEndDate_TIME'
]
});
Ext.define('CatalogItem', {
extend: 'Ext.data.Model',
fields: [
'catalogitemID',
'catalogID',
'catalogitemValue',
]
});


var biddocfiletype_catalogitemstore = Ext.create('Ext.data.Store', {
model: 'CatalogItem',
autoLoad: false,
remoteSort: true,
proxy: {
type: 'ajax',
simpleSortMode: true,
url: '/catalogitem/comboboxxml/catalogID/200',
reader: {
type: 'xml',
totalProperty: 'TotalResults',
record: 'CatalogItem'
}
}
});
var bidstore = Ext.create('Ext.data.Store', {
model: 'Bid',
autoLoad: false,
remoteSort: true,
proxy: {
type: 'ajax',
simpleSortMode: true,
url: '/bid/comboboxxml/',
reader: {
type: 'xml',
totalProperty: 'TotalResults',
record: 'Bid'
}
}
});

//Form
var formPanel = Ext.create('Ext.form.Panel', {
renderTo: 'form',
url:'/biddoc/dosavereupload',
standardSubmit: false,
width: 1000,
bodyPadding: 0,
border: 0,
waitMsgTarget: true,


fieldDefaults: {
labelAlign: 'right',
labelWidth: 250,
msgTarget: 'under'
},


// configure how to read the XML data
reader : Ext.create('Ext.data.reader.Xml', {
model: 'BidDoc',
record : 'BidDoc',
successProperty: '@success'
}),


// configure how to read the XML errors
errorReader: Ext.create('Ext.data.reader.Xml', {
model: 'example.fielderror',
record : 'field',
successProperty: '@success'
}),
items: [{
xtype: 'fieldset',
title: 'ReUpload - Bid Doc',
items: [{
fieldLabel: 'ID',
name: 'biddocID',
itemId: 'biddocID',
xtype: 'textfield',
readOnly: true,
emptyText: 'ID'
},
{
fieldLabel: 'File',
xtype: 'filefield',
name: 'fileupload',
width: 750,
allowBlank: false
}
]


}],


buttons: [{
text: 'Save',
formBind: true,
handler: function(){
this.up('form').getForm().submit({
url:'/biddoc/dosavereupload/',
submitEmptyText: false,
headers: {'Content-type':'multipart/form-data'},
isUpload:true,
waitMsg: 'Saving...',
success: function() {
window.location.href = '/biddoc/listbiddocs/';
}
});
}
}]
});



//load the data into the form
bidstore.load();
biddocfiletype_catalogitemstore.load();
formPanel.getForm().load({url: '/biddoc/LoadSingleXML/', waitMsg:'Loading'});
});


</script>
<br>
<div id="form"></div>

mitchellsimoens
16 Oct 2012, 6:35 AM
What are you returning? Any errors thrown?

bsmithinghamisd
16 Oct 2012, 4:39 PM
my php script replies back with. i set the header to xml too. so that's not the problem.


<message success="true">
<errors/>

</message>

mitchellsimoens
17 Oct 2012, 4:18 AM
Try returning JSON


{"success": true}

bsmithinghamisd
18 Oct 2012, 3:36 PM
Ok that worked. But I don't get it, my project is xml based. I'd prefer to stay with xml

bsmithinghamisd
29 Nov 2012, 4:57 PM
So I'm just getting back to this problem. I understand this works with JSON, anyway in getting this to work again with XML?