-
11 Jan 2012 1:14 PM #1
Show in list xml data from web service using store
Show in list xml data from web service using store
Hi, everyone! I'm newbie in Sencha Touch and I want to understand how it works with web services. My following code works fine with the xml file I hosted on my local web server. But, when I try to work with public web service, I get nothing. It's strange, cause xml files are absolutely the same and only one string of the code is different (only url). I mean, if to host the following xml file on web server and to set it as url of proxy, all'll be OK and data will be shown. But when to set url as 'http://www.thomas-bayer.com/sqlrest/INVOICE/605', which returns the same xml, you'll get nothing.
Here is my js-code:
Code:Ext.require([ 'Ext.Panel', 'Ext.tab.Panel', 'Ext.Ajax' ]); Ext.application({ name: 'Sencha', launch: function() { Ext.regModel('XMLUser', { fields: ['ID', 'CUSTOMERID', 'TOTAL'] }); var XMLStore = new Ext.data.Store({ model: 'XMLUser', implicitIncludes: true, method:'get', proxy: { type: 'ajax', url : 'http://www.thomas-bayer.com/sqlrest/INVOICE/605', //url: 'test1.xml', reader: { type : 'xml', record: 'INVOICE' } }, autoLoad: true }); var XMLTpl = new Ext.XTemplate( '<tpl for=".">', '<div class="id-class" id="{ID}">{ID}', '<div>{CUSTOMERID}', '<div>{TOTAL}', '</tpl>' ); Ext.create("Ext.TabPanel", { fullscreen: true, tabBarPosition: 'bottom', items: [ { xtype: 'list', title: 'Blog', iconCls: 'home', itemTpl: XMLTpl, store: XMLStore, singleSelect : true } ] }).setActiveItem(0); } });Here is the sample of xml-file (and you will get it by address: http://www.thomas-bayer.com/sqlrest/INVOICE/605):
Code:<?xml version="1.0"?><INVOICE xmlns:xlink="http://www.w3.org/1999/xlink"> <ID>605</ID> <CUSTOMERID xlink:href="http://www.thomas-bayer.com/sqlrest/CUSTOMER/505/">505</CUSTOMERID> <TOTAL>209505</TOTAL> </INVOICE>
-
11 Jan 2012 1:50 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
So this is cross origin? browsers put security restrictions on ajax calls
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
11 Jan 2012 11:14 PM #3
Hmmmm.Is there any option to turn this policy off (I tested it in Chrome and Firefox)? And how to provide this fact?
-
12 Jan 2012 5:45 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
No, there is no way. If you were using JSON in stead of XML then you could use the JsonP which allows cross-origin.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote