1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    porpoise is on a distinguished road

      0  

    Default Answered: Issues Grabbing JSON - I'm so close.

    Answered: Issues Grabbing JSON - I'm so close.


    Hi all,

    Sooooo close to nailing this but I can't get it to work. Problem is that it's not loading the JSON and displaying it. My JSON file is valid (I checked it at JSON Lint) and is very simple. Here's the JSON which is in the same directory as app.js:

    Code:
    {
        "firstName": "John",
        "lastName" : "Smith"
    }
    And my Sencha Touch code:

    Code:
    var App = new Ext.Application({
        name: 'ExpEng',
        useLoadMask: true,
        launch: function () {
    
    
            Ext.regModel('Work', {
                fields: [
                    { name: 'firstName', type: 'string' },
                    { name: 'lastName', type: 'string' }
                ]
            });        
    
    
            Ext.regStore('workStore', {
                model: 'Work',
                proxy: {
                    type: 'ajax',
                    url: 'sample.json',
                    reader: {
                        type: 'json'
                    } 
                }
                //data: [
    		      //  { id: 1, date: new Date(), title: 'Test Note', narrative: 'This is simply a test note' }
    		    //]
            });
    
    
            ExpEng.views.workList = new Ext.List({
    			    id: 'workList',
    			    store: 'workStore',
    			    onItemDisclosure: function (record) {
    			        //TK
    			    },
    			    itemTpl: '<div class="list-item-title">{firstName}</div>'
    		});        
    
    
            ExpEng.views.workListContainer = new Ext.Panel({
                id: 'workListContainer',
                layout: 'fit',
                html: 'This is the work list container',
                items: [ExpEng.views.workList]
            });
    
    
            ExpEng.views.viewport = new Ext.Panel({
                fullscreen: true,
                layout: 'card',
                cardAnimation: 'slide',
                items: [ExpEng.views.workListContainer]
            });
        }
    });
    You'll note the commented out data which is what I was using to make sure that the store was communicating with the model - which it was - it showed up just fine. I tried to take it to the next level by snagging this JSON file but it ain't working.

    Thanks for the help!

  2. I replaced my JSON code with this:

    Code:
    [
        {
            "firstName": "John",
            "lastName" : "Smith"
        }
    ]
    But the app just hangs on the loading icon...

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


    Your JSON is valid but it's not. The Store is expecting an Array:

    Code:
    [
        {
            "firstName": "John",
            "lastName": "Smith"
        }
    ]
    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
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    porpoise is on a distinguished road

      0  

    Default Made the change

    Made the change


    I replaced my JSON code with this:

    Code:
    [
        {
            "firstName": "John",
            "lastName" : "Smith"
        }
    ]
    But the app just hangs on the loading icon...

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


    Odd... worked 100% for me.
    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
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    porpoise is on a distinguished road

      0  

    Default Error I get

    Error I get


    I get this error in console:

    TypeError: 'undefined' is not an object (evaluating 'a.length')

    It says it's in sencha-touch.js:6

    Does that yield any clues?

  7. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    porpoise is on a distinguished road

      0  

    Default Updated error

    Updated error


    Oops. That wasn't very helpful, was it. From the debug.js I get this error from console:

    TypeError: 'undefined' is not an object (evaluating 'records.length')

    from

    sencha-touch-debug:7231

  8. #7
    Sencha User
    Join Date
    Dec 2011
    Posts
    5
    Answers
    1
    Vote Rating
    0
    porpoise is on a distinguished road

      0  

    Default Solved it!

    Solved it!


    Ha - solved it. I wasn't running my app from a web server. I did that and now it works! Thanks for your help!!

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar