PDA

View Full Version : Process XML from AJAX Form submit



preaction
29 Sep 2011, 10:02 AM
How do I process XML from an AJAX form submit?

The docs seem to say I can use a reader: in form like I can in a Store, but I tried this and it still tried to process the result as JSON.



Ext.define('MY.view.Browser', {
extend : 'Ext.form.Panel',
alias : 'widget.browser',
url : '/rest/search',
reader : {
type : 'xml',
root : 'searchList',
record : 'item'
}
});


I also tried specifying the reader property next to the instance I was creating, but that didn't work either.

I was originally going to use a Store for this, but it's a search that must be loaded into a Tree whose branches can be opened (the search results are always branches of the tree with children to grab).

preaction
29 Sep 2011, 10:29 AM
Looking more closely at the docs, it seems that "reader" is for load() only. "errorReader" is for submit(), but I still can't get errorReader to work when in the config object of my Ext.define().

Only if I specify form.errorReader = Ext.create( ... ); does my errorReader seem to get used in the action response.

margozzi
2 May 2012, 2:51 PM
We are facing the same issue. Sadly I see no one has responded to you. It is really odd that there seems to be no way to get a hook into the form submit to allow you to add your own errorReader. There is no docs for the errorReader, yet there it is in the source code. So for us, our failure function never gets called. Deep in the ExtJS code they try and read the response object but not the responseXML which is what we want to read.

Did you get things to work with the approach you describe above?

preaction
2 May 2012, 2:53 PM
Yes, it worked, but considering the name I don't know for how long (it's not an error, it's a success). I haven't updated to 4.0.7 or the 4.1 beta yet, so YMMV if you have.

margozzi
2 May 2012, 2:57 PM
Unfortunately XML is a second class citizen to json with this framework. We spend lots of time and effort making it work. We eventually get there ...but way too much effort, sigh. Thanks for your post and quick response I appreciate that very much.

P.S. We are running 4.0.7a.