1. #1
    Sencha User CSchmitz81's Avatar
    Join Date
    Nov 2012
    Location
    Saint Louis
    Posts
    33
    Vote Rating
    0
    Answers
    3
    CSchmitz81 is on a distinguished road

      0  

    Default Answered: Problems getting my store's proxy config to work

    Answered: Problems getting my store's proxy config to work


    I'm trying to build a simple rss reader to get a handle on how stores work. I created the shell of the application and set up a list view with an item template, the correct model, and then created a store with inline data to verify it worked (which it did).

    I then tried commenting out my inline data in the store and replaced it with a proxy configuration to try to read directly from the rss feed's xml file and I can't get it to work. I'm not sure what I'm missing and really I'm not sure where to check in my browser's dev tools to troubleshoot.

    I also tried saving the xml to a file I stored within my project and changed my proxy config to use ajax and pointed it to the local file (you can see those config lines commented out) just to see if there was an error with getting it from the external domain and it still did not work.

    Could anyone help point me in the right direction?

    Here's my store's code:

    Code:
    Ext.define('DorklyReader.store.Feed',{
        extend: 'Ext.data.Store',
        requires: ['Ext.data.proxy.JsonP', 'Ext.data.reader.Xml'],
    
    
        config:{
            model: 'DorklyReader.model.Feed',
    
    
            proxy: {
                type: 'jsonp',
                url: 'http://www.dorkly.com/rss',
                // type: 'ajax',
                // url: 'store/exampleFeed.xml',
                reader: {
                    type: 'xml',
                    record: 'items',
                    rootProperty: 'items'
                },
                autoload: true
            }
    
    
    //The app works when reading from this inline data:
        //     data: [
        // // Build with sample data first before building the proxy section. 
        //     {guid: '1234', link: 'http://www.google.com', title: 'dog jumps over log', description: 'wow what a dog!'},
        //     {guid: '5678', link: 'http://www.google.com', title: 'cat sits on hat', description: 'typical cat!!'},
        //     {guid: '9098', link: 'http://www.google.com', title: 'fish swims!', description: 'who could have seen that coming?!!'},
        //     ]
        }
    });

  2. There is no xml proxy, you need to use ajax proxy. If you are wanting to do cross origin requests then the server will need to support CORS which is just a couple headers returned by the server and it will just work. http://enable-cors.org/

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    872
    Answers
    3566
    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


    jsonp proxy will only work with json not xml but requires more than just plain json.

    autoload should be autoLoad and on the store not the proxy.
    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.

  4. #3
    Sencha User CSchmitz81's Avatar
    Join Date
    Nov 2012
    Location
    Saint Louis
    Posts
    33
    Vote Rating
    0
    Answers
    3
    CSchmitz81 is on a distinguished road

      0  

    Default


    Ah gotcha.

    When I was reading the documentation on proxies: http://docs.sencha.com/touch/2-1/#!/...ta.proxy.Proxy

    I misunderstood the line:
    JsonP - uses JSON-P to send requests to a server on a different domain
    thinking that I needed to use JSON-P anytime I wanted to send requests to a different domain
    vs
    I needed to use JSON-P anytime I wanted to send requests to a different domain using json.

    So in the end, in addition to the autoLoad changes, I need to change my proxy type to 'xml' and that should resolve the issue, right?

    Also (assuming that is the correct answer), where would I have found that in the documentation? On the doc page for touch's proxies it doesn't list types that deal with external servers other than Json-P (unless I'm missing it).

    Thanks for your response!

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    872
    Answers
    3566
    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


    There is no xml proxy, you need to use ajax proxy. If you are wanting to do cross origin requests then the server will need to support CORS which is just a couple headers returned by the server and it will just work. http://enable-cors.org/
    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.

  6. #5
    Sencha User CSchmitz81's Avatar
    Join Date
    Nov 2012
    Location
    Saint Louis
    Posts
    33
    Vote Rating
    0
    Answers
    3
    CSchmitz81 is on a distinguished road

      0  

    Default


    Cool. Thanks for the help!

Thread Participants: 1

Tags for this Thread