View Full Version : Retrieving data from .json file
Sneha004
24 Jan 2012, 2:59 AM
Hi,
Can anyone help me with following question
Retrieving data from .json file directly without using store and model?
kindly suggest some solutions
Sneha004
24 Jan 2012, 3:07 AM
{
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
vietits
24 Jan 2012, 6:30 AM
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':
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);
}
});
jay@moduscreate.com
24 Jan 2012, 9:33 AM
Here is an article i wrote a looooooooong time ago on Ajax: http://www.sencha.com/learn/legacy/Manual:Core:Ext.Ajax
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.