1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default 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>

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,546
    Vote Rating
    873
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    So this is cross origin? browsers put security restrictions on ajax calls
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default


    Hmmmm.Is there any option to turn this policy off (I tested it in Chrome and Firefox)? And how to provide this fact?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,546
    Vote Rating
    873
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread