PDA

View Full Version : Ext.Ajax.request Post XML formatted data



j11extjs
9 Sep 2010, 11:05 PM
I am calling Ext.data.XmlStore.getModifiedRecords() which returns to me an array of modified records. I do some further processing on this to give me an JSON-encoded string of each of the dirty records.
I then call the Ext.Ajax.request passing this JSON-encoded string as a params configuration object. On the server-side I use a reader to get the HttpRequest.InputStream and I get the data fine.

The alternative way is to associate a XmlWriter to XmlStore which causes a POST of data in xml format and I get a xml-formatted data from the same HttpRequest.InputStream above using a reader.

I would like to be able to SEND (from client, and RECEIVE in server) xml formatted data like the latter using Ext.Ajax.request like the former. How? thanks!

PS. (my server-side code is .NET C#)

Condor
9 Sep 2010, 11:13 PM
Ext.Ajax.request({
url: '...',
xmlData: xmlAsString,
success: function(response){
var xml = response.responseXML;
...
}
});

j11extjs
9 Sep 2010, 11:38 PM
Ext.Ajax.request({
url: '...',
xmlData: xmlAsString,
success: function(response){
var xml = response.responseXML;
...
}
});


Thanks for the reply. I have tried that use of xmlData. My main issues are:
1) Do I leave params config object empty since the information I want to pass will already go to xmlData and I get an error if I leave out params even though the API documentation says it is optional?
2) how do I convert the array of objects returned by the call to Ext.data.XmlStore.getModifiedRecords() to an xml string that I can use for xmlData?

Many thanks.

Condor
10 Sep 2010, 12:21 AM
1. params are indeed optional. You shouldn't get an error when omitting them.
2. Have a look at how XmlWriter does this (with an XTemplate).

squalo
9 Mar 2011, 6:54 AM
What I'm doing wrong in getting this error in Firebug:

"xmlAsString is not defined"

Thx

fay
9 Mar 2011, 7:19 AM
And have you defined a variable "xmlAsString" which contains the xmlData you want to post/send?

EDIT: xmlAsString is obviously something (a variable) the original poster created, i'm guessing, containing the xmlData s/he wants to send to the server.

squalo
9 Mar 2011, 7:37 AM
Maybe I complete wrong here.
I only want to load another XML File into my store while a certain panel is expanded.



listeners: {
expand: function(panel) {
Ext.Ajax.request({
url: '../configuration.xml',
method: 'GET',
//xmlData: xmlAsString,
success: function(response, opts) {
var obj = Ext.decode(response.responseXML);
console.log(obj);
store.loadData(obj);
},
....
when I run this above I get this Error in FB:
" missing ] after element list
([object XMLDocument])"

but the GET seemed to be successful IMO, because I can see all the new XML data in Firebug.

Condor
9 Mar 2011, 8:09 AM
You're JSON decode()-ing XML data. Doesn't that sound weird to you?

var obj = response.responseXML;

squalo
9 Mar 2011, 8:35 AM
Thx and Sorry.

I'm getting really weired after each day struggling 8h with Ext JS to get my probs solved anyway.

regards