Results 1 to 4 of 4

Thread: Show in list xml data from web service using store

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Vote Rating
    1270
      0  

    Default

    So this is cross origin? browsers put security restrictions on ajax calls
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Vote Rating
    1270
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •