私はyiiフレームワークを使用してExtJs4でWebサイトを開発しています。サーバーからExtjs4に返されたjsonデータにアクセスする方法に行き詰まっています。実際には、メッセージフィールドとjsonコードのすべてのフィールドを表示したいと思います。 ext js 4.ではどうすればよいですか?
これが私のjsonコードです(json形式のサーバー応答)
{
"success": true,
"data": [
{
"msg": "uname and pass wrong"
}
]
}
これが私のモデルクラスコードです
Ext.define('AM.model.Login',
{
extend:'Ext.data.Model',
idProperty:'id',
fields:['id','uname','pass'],
proxy:
{
type:'ajax',
url:'http://localhost/Balaee3/index.php?r=site/contact',
reader:
{
type:'json',
root:'data',
successProperty:'success'
},//end of reader
writer:
{
type:'json',
root:'records',
//writeAllFields:true
},//End of writer
}//end of proxy
}
);
ext js4のコントローラーファイルのjsonコードにアクセスするにはどうすればよいですか? ここでjsonデータを表示したいと思います。
AM.model.Login.load(512, {
params: {
id: 512
},
success: function(record, operation) {
character = record;
},//end of success
failure: function(record, operation)
{
Ext.Msg.alert('Error', 'Failed to load model from the server.');
},//end of failure
callback: function(record, operation) {
//Ext.Msg.alert('Success', 'Model loaded successfully.');
console.log('Success', 'Model loaded successfully.');
}//end of call back function
});
いくつかの提案をください