PDA

View Full Version : ScriptTagProxy and JSONP wrapped XML response



r4nd7263
21 Jul 2011, 5:55 AM
Is it possible to use ScriptTagProxy to handle XML data wrapped in JSONP?


Something like:


var store = new Ext.data.Store({
model : 'MyModel',
proxy : {
type : 'scripttag',
url : 'http://domain2/rest/jsonp/myModel/10000',
reader : {
type : 'xml',
record : 'MyModel'
}
}
})
The server returns (with text/javascript):



stcCallback1001('<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<MyModel><id>10231<\/id><\/MyModel>')
I tried and got this error: 'Uncaught TypeError: Cannot call method 'querySelectorAll' of null'

Not sure if I didn't return the correct data format, or ScriptTagProxy simply can't handle XML data wrapped in JSONP response. Or something else went wrong.

mitchellsimoens
21 Jul 2011, 9:58 AM
Why not use JSON then?

r4nd7263
21 Jul 2011, 11:01 AM
That's fine. I was wondering if ScriptTagProxy supported wrapped XML, just not yet documented.

Our web service for native Android apps are serving XML in production, so I thought to reuse it that's all. If not, we will update it to support JSON as well

Hertz
21 Jul 2011, 4:04 PM
If developing for iOS, and wrapping with Phonegap, you could just use Ext.Ajax and you don't have to worry about cross-domain policies.

I do the testing with Safari on a mac (only browser and only platform to be able to test in my experience). But users won't have a problem accessing the info through your app in their devices, neither you while testing on the simulator with Xcode.

ilija139
10 Sep 2011, 12:02 PM
Thanks Hertz!