Results 1 to 6 of 6

Thread: JsonP store and trouble with reader

  1. #1
    Sencha User
    Join Date
    Oct 2007
    Posts
    256
    Answers
    2

    Default JsonP store and trouble with reader

    Having some issues with loading data in my store using JsonP.

    I have a facebook page which I need to load my json data from.
    https://www.facebook.com/feeds/page....48&format=json

    Every time it error out and not able to load my data. I am not sure what is that I am not doing right.

    my codes are as follows.

    Code:
    Ext.define('myApp.store.MyFeedStore', {    extend: 'Ext.data.Store',
    
    
        requires: [
            'myApp.model.MyFeed',
            'Ext.data.proxy.JsonP',
            'Ext.data.reader.Json'
        ],
    
    
        config: {
            autoLoad: true,
            model: 'myApp.model.MyFeed',
            storeId: 'MyFeedStore',
            proxy: {
                type: 'jsonp',
                url: 'https://www.facebook.com/feeds/page.php?id=6815841748&format=json',
                callbackKey: 'jsoncallback',
                reader: {
                    type: 'json',
                    record: 'entries'
                }
            }
        }
    });

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User
    Join Date
    Oct 2007
    Posts
    256
    Answers
    2

    Default

    Quote Originally Posted by evant View Post
    Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.
    Just to clear.
    I cannot use the JsonP with my store and proxy. I have to make a call like below?
    Code:
    Ext.data.JsonP.request({    url: 'http://example.com/script.php',
        callbackKey: 'callback',
        params: {
            data: Ext.encode(values)
        },
        success : function(response) {
          console.log("Spiffing, everything worked");
          // success property
          console.log(response.success);
          // result property
          console.log(response.result);
       },
       failure: function(response) {
            console.log(response);
            Ext.Msg.alert('Error', 'Please try again.', Ext.emptyFn);
        }
    });

  4. #4
    Sencha User
    Join Date
    Oct 2007
    Posts
    256
    Answers
    2

    Default

    Quote Originally Posted by evant View Post
    Would suggest you read the introductory docs about how the jsonp proxy works, it's quite detailed and explains how it all works. After that you'll see why it doesn't work.
    Still don't understand how to use the JsonP after reading docs.

    Can someone just give me a hint what I am doing wrong,

    All I want is to load the json data from the url to the store.

  5. #5
    Sencha User
    Join Date
    Oct 2007
    Posts
    256
    Answers
    2

    Default

    Is this breaking because the return result from FB is not Ext.data.JsonP.callback({ "data": { .....??

  6. #6
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    Yes, that's right. That's how JSONP works, it needs to call the callback function passed as part of the URL. Otherwise you don't know when it's complete.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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