1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    26
    Vote Rating
    1
    MrBeef is on a distinguished road

      0  

    Default JSON & DataView

    JSON & DataView


    I've tried many different examples, but I can't seem to get this right. I want to load an Ext.DataView from a PHP file that prints JSON.

    Here's an example of the JSON output:
    Code:
    {"households":[[{"HHName":"Jim Smith Household"}]]}
    Here's my model:
    Code:
        Ext.regModel('household', {
            fields: [{name: 'HHName', type: 'string'}]
        });
    and here's my DataView that I display in a TabPanel later...I'd appreciate any help with getting this working. Thanks!

    Code:
    var list = new Ext.DataView({
            store: new Ext.data.Store({
                model: 'household',
                proxy: {
                    type: 'ajax',
                    url: 'http://mywebsite.com/get_households.php',
                    reader: {
                        type: 'json',
                        root: 'households'
                    }
                }
            }),
            tpl: new Ext.XTemplate(
            '<tpl for=".">',
                '<div>',
                    '{HHName}',
                '</div>',
            '</tpl>'
        )
    });

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    18
    Vote Rating
    0
    amussini@gmail.com is on a distinguished road

      0  

    Default


    If your call is cross-domain, you should use jsonp, not ajax...

    Code:
    proxy: {
                    type: 'ajax',
                    url: 'http://mywebsite.com/get_households.php',
    
    
    proxy: {
                    type: 'jsonp',
                    url: 'http://mywebsite.com/get_households.php',

Thread Participants: 1