View Full Version : How to expect String in AJAX response?

23 Apr 2012, 8:31 PM
I'm uploading a file through HTTP header without the use of PHP. Response from server is a String, not JSON or XML.

In the following code, can I set errorReader to expect a String instead of JSON or XML?

id: 'uploadPanel',
xtype: 'panel',
errorReader: new Ext.data.reader.Xml({
record : 'field',
success: '@success'
}, [
'id', 'msg'
items: [{
xtype: 'filefield',
name: 'file',
fieldLabel: 'File',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: "Select File"

buttons: [{
text: prefLabels.systemUpgrade.btnUpload.label,
handler: function() {
var form = currentScreen.getComponent('uploadPanel').getForm();
url: '/cgi-bin/upload.rb',
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);

/cgi-bin/upload.rb = our version of PHP

upload.rb responds with:
File Uploader 1.0

It's not hitting the form's success or failure functions.

Chrome Console window shows:
Uncaught TypeError: Cannot read property 'prototype' of undefined

1 May 2012, 6:36 AM
You're getting an error as you are telling the form to decode XML. You can create your own simple reader to read a string.

16 May 2012, 9:55 AM

If I do this : errorReader: new Ext.data.reader.Reader({
I get this error:
Uncaught TypeError: Cannot read property 'records' of undefined

I think it is because it is expecting a result of
{ records: recordArray}
when the (success) result is
LS File Uploader 1.0

16 May 2012, 10:22 AM
To be honest, upload.rb needs to response with JSON