View Full Version : Form with XML on server - how to access the response?

4 Feb 2010, 5:52 AM

I have a form that I have posted to the server, it has an XML response instead of JSON, so I am trying to understand how I can get access to the response within the success handler.

I have learnt that because my response is not JSON, I need to provide an errorReader to prevent errors when EXT tries to decode the response as JSON when it's actually XML. Is there any way of disabling the automated error checking - I only want to check the response contains a couple of XML elements.

I can get access to the XML text via action.response.responseText, but I really want this parsed into an object (similar to what JSON does), so that I can use the record, something like

var loggedInUser = result.userId;

Could anyone explain how I can pass a record into the config (or at some other stage), so that I might be able to read the values how I intended to?

function createLoginForm() {
return { xtype: 'form',
id: 'login-form',
bodyStyle: 'padding:15px;background:transparent',
border: false,
errorReader: new Ext.data.XmlReader({
record: 'loginCredentials',
success: 'userId'
items: [
{ xtype: 'box',
autoEl: { tag: 'div',
html: '<div class="app-msg"> <img src="img/magic-wand.png" class="app-img" />Log in to The Magic Forum</div>'
{ xtype: 'textfield',
id: 'email',
fieldLabel: 'Username', allowBlank: false, minLength: 3, maxLength: 32, msgTarget:'side'},
{ xtype: 'textfield', id: 'password', fieldLabel: 'Password',
inputType: 'password', allowBlank: false, minLength: 6,
maxLength: 32, minLengthText: 'Password must be at least 6 characters long.',
], buttons: [{
text: 'Sign In', handler: function() {
Ext.getCmp('login-form').getForm().submit( {
waitMsg: 'Please wait...',
success: function (form,action) {

console.info('Okay','Looks like you logged in okay! response was... ');
failure: function (f,a) {
Ext.Msg.alert('Warning','Sorry, the details you entered are incorrect!');
},{ text: 'Join Now',handler: function() {
Ext.Msg.alert("'Join now' has not yet been written!");
} }]};