1. #1
    Ext User
    Join Date
    Nov 2010
    Posts
    1
    Vote Rating
    0
    Student4Gold is on a distinguished road

      0  

    Default Cannot read property 'length' of undefined

    Cannot read property 'length' of undefined


    Hello,

    Im a freshman in json and sencha framework.

    I am working on an app and at first i want to get Data from our webservice and display it in a gridview.
    But i get this error " Cannot read property 'length' of undefined".

    This is the output of the PHP:
    Code:
    [{"id":"198","product_id":"15","NAME":"Markenjodsalz","amount":"250","UNIT":"g","quantaty":"1"},{"id":"220","product_id":"48","NAME":"Magarine","amount":"500","UNIT":"g","quantaty":"2"},{"id":"209","product_id":"49","NAME":"H fettarme Milch","amount":"1","UNIT":"Liter","quantaty":"1"},{"id":"218","product_id":"87","NAME":"Milchschnitte","amount":"4","UNIT":"St","quantaty":"1"},{"id":"217","product_id":"153","NAME":"Mixery","amount":"1","UNIT":"Flasche","quantaty":"1"},{"id":"219","product_id":"173","NAME":"Gouda gerieben","amount":"200","UNIT":"g","quantaty":"1"}]
    And i took the example-code from the api-documentation:
    Code:
    Ext.regModel('User', {
        fields: [
    			{name: 'id', type: 'int'},
    			{name: 'product_id', type: 'int'},
    			{name: 'amount', type: 'int'},
    			{name: 'quantaty', type: 'int'},
    			'NAME', 'UNIT'
    		]
    });
    
    var myStore = new Ext.data.Store({
        model: 'User',
        proxy: {
            type: 'ajax',
            url : '*****/iphone/shoppinglist.php',
            reader: {
                type: 'json',
                root: 'users'
            }
        },
        autoLoad: true
    });
    Don't know what i am doing wrong.

    Thanks for help

  2. #2
    Sencha User
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    293
    Vote Rating
    5
    Stuart-SwarmOnline will become famous soon enough

      0  

    Default


    Your reader defines a root of 'users' but your json response is just an array. Change your PHP to output something like...

    Code:
    {'users': [{...}, {...}]}

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    5
    Vote Rating
    0
    fyghtsoft is on a distinguished road

      0  

    Default Great!

    Great!


    That was the correct answer for and solved my issue. Thanks.

Similar Threads

  1. Uncaught TypeError: Cannot read property 'length' of undefined
    By a2rdvark in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 23 Dec 2010, 3:48 PM
  2. Cannot read property 'leaf' of undefined
    By SIDGEY in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 4 Oct 2010, 1:41 AM
  3. Cannot read property 'ownerCt' of undefined
    By qbert65536 in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 23 Sep 2010, 3:42 PM
  4. TypeError: Cannot read property 'parentNode' of undefined
    By zurdophp in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 2 Sep 2010, 5:58 AM
  5. Cannot read property 'prototype' of undefined
    By flyboarder in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 3 May 2010, 2:19 PM

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi