1. #1
    Sencha User
    Join Date
    Nov 2012
    Location
    Mumbai, India
    Posts
    7
    Vote Rating
    0
    sirwanimayur is on a distinguished road

      0  

    Default Unanswered: Data not coming from jsonp

    Unanswered: Data not coming from jsonp


    Not able to see any data in this list
    Any guess why it is not working

    Code:
    Ext.define("StockWatch.view.MarketList", {    extend: "Ext.dataview.List",
    	requires: "Ext.plugin.PullRefresh",
        xtype: "marketlist",
        config: {
            loadingText: "Loading Markets...",
    		layout: 'fit',
    		plugins: [
                {
                    xclass: 'Ext.plugin.PullRefresh',
                }
    		],
    		store: {
    			fields : ['CompanyCode','LastTradedPrice'],
                proxy : {
    				type:'jsonp',
                    url:'http://money.rediff.com/money1/current_status_new.php?companylist=17023928%7C17023929&id=1354690151&Rand=0.6305125835351646',
    				callbackKey: 'callbackJsonp',
                    reader: {
    					type: 'json',
    					rootProperty: ''
                    }
                },
                autoLoad:true,
            },
            emptyText: '</pre><div>No markets found.</div><pre>',
            onItemDisclosure: false,
            itemTpl: '</pre><div>{CompanyCode}</div><div>{LastTradedPrice}</div><pre>',
        }
    });

  2. #2
    bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    44
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    At first glance I see you have some trailing commas sprinkled about in your code. Also, have you reviewed your error console when you run your code? What does that report? Have you verified that your service is returning your callback as expected? Check this stuff out then post more details/information if necessary.

    Brice
    Brice Mason
    Front End Developer
    Modus Create

    @bricemason
    bricemason.com

    Sencha Touch Screencasts
    Vimeo - Sencha Touch Channel

    Github Projects:
    Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.

    Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.

    Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Location
    Mumbai, India
    Posts
    7
    Vote Rating
    0
    sirwanimayur is on a distinguished road

      0  

    Default


    console has no error, just a warning, the server returned ot as a script but changing it to text/html or some kind of this...

    i'm getting this response when i hit url on browser

    [{"CompanyCode":"17023928","LastTradedPrice":"19,476.00","Volume":"0","PercentageDiff":"0.57","FiftyTwoWeekHigh":"19,612.18","FiftyTwoWeekLow":"15,135.86","LastTradedTime":"19 Dec,16:00:21","ChangePercent":"0.57","Change":"111.25","MarketCap":"0.00","High":"19,516.02","Low":"19,419.76","PrevClose":"19,364.75","OpenInterest":"","MarketLot":"","ChangeInOpenInterest":"","Symbol":null},{"CompanyCode":"17023929","LastTradedPrice":"5,929.60","Volume":"0","PercentageDiff":"0.56","FiftyTwoWeekHigh":"5,965.15","FiftyTwoWeekLow":"4,588.05","LastTradedTime":"19 Dec,16:27:55","ChangePercent":"0.56","Change":"32.80","MarketCap":"0.00","High":"5,939.40","Low":"5,910.80","PrevClose":"5,896.80","OpenInterest":"","MarketLot":"","ChangeInOpenInterest":"","Symbol":""}]

    I dnot know how to check if server is returning a callback thing that u r saying

  4. #4
    bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    44
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    Your json encoded data is not wrapped in a callback function. See the docs for the jsonp proxy here:

    http://docs.sencha.com/touch/2-1/#!/...ta.proxy.JsonP

    The second code figure in those docs will show you the difference in your data.

    Brice
    Brice Mason
    Front End Developer
    Modus Create

    @bricemason
    bricemason.com

    Sencha Touch Screencasts
    Vimeo - Sencha Touch Channel

    Github Projects:
    Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.

    Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.

    Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.

  5. #5
    Sencha User
    Join Date
    Nov 2012
    Location
    Mumbai, India
    Posts
    7
    Vote Rating
    0
    sirwanimayur is on a distinguished road

      0  

    Default


    So that means I wont be able to show this data on list??
    any way on how to achieve this?

  6. #6
    bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    44
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    You can certainly show that data. You just need to fix what's returned from your jsonp service. The snippet I was referring to in the docs was this:

    Code:
    someCallback({
        users: [
            {
                id: 1,
                name: "Ed Spencer",
                email: "ed@sencha.com"
            }
        ]
    });
    This snippet demonstrates the data being wrapped in a callback.

    Your proxy has a custom callback key of callbackJsonp. This is telling your service to use the callback name that's defined in the querystring parameter of callbackJsonp. If you inspect the url that's being requested with your proxy you'll see that.

    I recommend reading the docs for JsonP proxy very carefully so you can get the concept down.

    Brice
    Brice Mason
    Front End Developer
    Modus Create

    @bricemason
    bricemason.com

    Sencha Touch Screencasts
    Vimeo - Sencha Touch Channel

    Github Projects:
    Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.

    Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.

    Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Location
    Mumbai, India
    Posts
    7
    Vote Rating
    0
    sirwanimayur is on a distinguished road

      0  

    Default


    That is some external API I'm using, I cant edit that

  8. #8
    bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    44
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    Then in that case I'd recommend just creating your own server-side facade that interacts with that service. Then you can just use an ajax proxy.

    Brice
    Brice Mason
    Front End Developer
    Modus Create

    @bricemason
    bricemason.com

    Sencha Touch Screencasts
    Vimeo - Sencha Touch Channel

    Github Projects:
    Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.

    Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.

    Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.

  9. #9
    Sencha User
    Join Date
    Nov 2012
    Location
    Mumbai, India
    Posts
    7
    Vote Rating
    0
    sirwanimayur is on a distinguished road

      0  

    Default


    Ohk
    Any idea if I can read this data as string and then parse it to json and display it on the client side itself?

  10. #10
    bricemason's Avatar
    Join Date
    Jan 2008
    Location
    Upstate NY
    Posts
    280
    Answers
    49
    Vote Rating
    44
    bricemason has a spectacular aura about bricemason has a spectacular aura about bricemason has a spectacular aura about

      0  

    Default


    No real need to parse it unless you want to change it in any way inside your facade. But if you just want the data itself, your facade would basically:
    1. Perform GET request of http://money.rediff.com/money1/current_status_new.php?companylist=17023928|17023929&id=1354690151&Rand=0.6305125835351646
    2. Print the data that's returned from that request
    Then you'd use an ajax proxy (http://docs.sencha.com/touch/2-1/#!/...ata.proxy.Ajax) with your json reader just like you had before.

    Brice
    Brice Mason
    Front End Developer
    Modus Create

    @bricemason
    bricemason.com

    Sencha Touch Screencasts
    Vimeo - Sencha Touch Channel

    Github Projects:
    Sencha Cordova Builder enables the automatic creation, building, and running of PhoneGap (Cordova) projects with Sencha Touch.

    Am I Sencha Touch Ready? checks your system to determine what you need to do to start Sencha Touch development. If you're having trouble getting up and running, try this out.

    Sencha Tools Bridge allows Sencha SDK Tools to co-exist with Sencha Cmd on the same system.

Thread Participants: 1

Tags for this Thread