View Full Version : Loading data from .json file

6 Jun 2012, 11:14 AM
Hi... I am new to extjs, been trying for only a few days. I am trying to read data from a json file, using extjs 4. I have tried with httpproxy and without just the url. I have also tried keeping the .json file everywhere possible just to check nothing was wrong with the url.
Currently my .json file is in the webapps directory of the tomcat server. The code is:

Ext.define('User', {
extend: 'Ext.data.Model',
fields: [{name:'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'email', type: 'string'}]

var user = Ext.create('Ext.data.Store', {
storeId: 'user',
model: 'User',
autoLoad: 'true',
proxy: {
type: 'ajax',
url : '/users.json',
reader: {type: 'json', root: 'blah'}

store :user,
id : 'user',
title: 'Users',
columns : [
{header: 'ID', dataIndex : 'id'},
{header : 'NAME', dataIndex : 'name'},
{header : 'Email', dataIndex: 'email'}
height :300,
width: 400,

The json file is:

{ blah[
"id": 1,
"name": "Ed Spencer",
"email": "ed@sencha.com"
"id": 2,
"name": "Abe Elias",
"email": "abe@sencha.com"

I am using liferay's tomcat server and extjs 4. Firebug says that the script is wrong. Can someone please help me out here? Thanks a lot!

6 Jun 2012, 12:47 PM
Please use [CODE] tags when posting code.

Your JSON isn't valid, there should be a colon after blah. Technically blah should also be double-quoted:

{"blah": [

Use a debugger (Firebug, Chrome Developer Tools or whatever you prefer) to watch the network activity. You should be able to see users.json being loaded from the server. That's a key diagnostic step as it helps to isolate which part of your system is incorrect.

6 Jun 2012, 4:23 PM
Duplicate post: