1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    36
    Vote Rating
    0
    Sneha004 is on a distinguished road

      0  

    Default Unanswered: Retrieving data from .json file

    Unanswered: Retrieving data from .json file


    Hi,

    Can anyone help me with following question

    Retrieving data from .json file directly without using store and model?

    kindly suggest some solutions

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    36
    Vote Rating
    0
    Sneha004 is on a distinguished road

      0  

    Default Repeat the previous Problem

    Repeat the previous Problem


    {
    success:true,
    userTimeZone:'CST',
    namevalue:
    [
    {id:'1',name:'one'},
    {id:'2',name:'two'},
    {id:'3',name:'three'},
    {id:'4',name:'four'}
    ]
    }


    The above one is json file
    I want to access the value of 'userTimeZone' directly in .js file without using store and model

  3. #3
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    100
    Answers
    343
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    You can use Ext.Ajax.Request() to retrieve the JSON file from server and then use Ext.decode() the JSON string to an object. With your example of JSON file, to retrieve JSON file and access 'userTimeZone':
    Code:
    Ext.Ajax.request({
        url: 'url to your JSON file',
        success: function(response, opts) {
            var obj = Ext.decode(response.responseText);
            console.log(obj.userTimeZone);     
        },
        failure: function(response, opts) {
            console.log('server-side failure with status code ' + response.status);
        }
    });

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,167
    Vote Rating
    29
    Answers
    83
    jay@moduscreate.com is a jewel in the rough jay@moduscreate.com is a jewel in the rough jay@moduscreate.com is a jewel in the rough jay@moduscreate.com is a jewel in the rough

      0  

    Default


    Here is an article i wrote a looooooooong time ago on Ajax: http://www.sencha.com/learn/legacy/Manual:Core:Ext.Ajax

    Jay Garcia @ModusJesus || Modus Create co-founder
    Ext JS in Action author
    Sencha Touch in Action author

    Get in touch for Ext JS & Sencha Touch Touch Training

    We are also working on Video-based Sencha Touch training: Check it out here.