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
    Answers
    346
    Vote Rating
    113
    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
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,360
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


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

Thread Participants: 2