How to load json data from ajax in ExtJs -


i try started extjs, , have quite basic question.
have model

ext.define('mb.model.user', {     extend: 'ext.data.model',     fields: [         { name: 'id', type: 'int' },         { name: 'name', type: 'string' },         ...     ],     proxy: {         type: 'ajax',         url : 'server/gui/getuser.php'     } }); 

getuser.php returns json string (it logged in user, , not user out of user table):

{"id":"1","name": ... } 

i tried following load data, error uncaught typeerror: object [object object] has no method 'load'

ext.define('mb.application', {     ...     launch: function() {         ....         user = ext.create('mb.model.user');         user.load();     } }); 

what correct way load data ?


an additional question: benefit of using modelhere ?

couldn't ?

ext.ajax.request({     url: 'server/gui/getuser.php',     success: function(response){     var user = ext.json.decode(response.responsetext);     } });   

in case load static method. can load model server passing id.

mb.model.user.load(id, {     success: function(rec) {         console.log('loaded', rec.getdata());     } }); 

the advantage using model layer of abstraction, + functionality using model.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -