EXTJS:如何把后台返回的json数据中的值赋给text
newExt.panel.Panel({title:'test',renderTo:Ext.getBody(),width:580,height:500,frame:tr...
new Ext.panel.Panel({
title: 'test',
renderTo: Ext.getBody(),
width: 580,
height: 500,
frame: true,
//layout: 'fit',
listeners: {
afterrender: function (o) {
Ext.Ajax.request({
url: "ASHX/UserSession.ashx",
method: "POST",
success: function (response, options) {
var res = response.responseText;
alert(res);//成功返回json后,如何赋值给text
}
});
}
},
items: [{
xtype: 'textfield',
id:'UserNames',
name: 'name',
fieldLabel: '姓名',
},
后台返回的json数据是{'UserName':'周杰伦','Branch':'中国分公司','Depart':'公关部'}
如何把json中的UserName赋值给text? 展开
title: 'test',
renderTo: Ext.getBody(),
width: 580,
height: 500,
frame: true,
//layout: 'fit',
listeners: {
afterrender: function (o) {
Ext.Ajax.request({
url: "ASHX/UserSession.ashx",
method: "POST",
success: function (response, options) {
var res = response.responseText;
alert(res);//成功返回json后,如何赋值给text
}
});
}
},
items: [{
xtype: 'textfield',
id:'UserNames',
name: 'name',
fieldLabel: '姓名',
},
后台返回的json数据是{'UserName':'周杰伦','Branch':'中国分公司','Depart':'公关部'}
如何把json中的UserName赋值给text? 展开
2个回答
展开全部
listeners: {
afterrender: function (o) {
var me = this;
Ext.Ajax.request({
url: "ASHX/UserSession.ashx",
method: "POST",
success: function (response, options) {
var res = Ext.decode(response.responseText);
me.down('textfield').setValue(res.UserName);
}
});
}
},
afterrender: function (o) {
var me = this;
Ext.Ajax.request({
url: "ASHX/UserSession.ashx",
method: "POST",
success: function (response, options) {
var res = Ext.decode(response.responseText);
me.down('textfield').setValue(res.UserName);
}
});
}
},
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询