ajax - How is a json file read? extjs -


say have fields here user in "json" format:

{     "users": [        {            "id": 1,            "name": "ed spencer",            "email": "ed@sencha.com"        },        {            "id": 2,            "name": "abe elias",            "email": "abe@sencha.com"        }     ] } 

i assume root here "users". save text users.json file?

and there, how read file (in case, ext.js)

ext.define('am.model.user', {     extend: 'ext.data.model',     fields: ['name', 'email'] });  var store = ext.create('ext.data.store', {     model: 'user',     proxy: {         type: 'ajax',         url : 'users.json',         reader: {             type: 'json',             root: 'users'         }     } }); 

what url? absolute path? work??? help!

in html page, javascript file served relative url of html page, or absolute path.

would save text users.json file?

you can, sure.

what url?

the url users.json relative url of html page running application, if html page @ http://localhost/myapp/index.html, relative path users.json same absolute path http://localhost/myapp/users.json

is absolute path?

no, users.json relative path. could use absolute path if wanted to.

i make data folder inside app folder , use app/data/users.json url.

you should learn chrome developer tools can see network requests.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -