您好我正在使用以下代码在我的移动应用程序中发送ajax请求
var button = new Ext.Toolbar({
cls: "top_tool_bar2",
height: 35,
items: [this.text,
{xtype: 'spacer'},
{html: new Ext.XTemplate('<img style="width:.5em;height:.5em;" src="resources/imgs/down_arrow.png" />').apply({name: 'down_arrow'}),
handler: function () {
Ext.Ajax.request({
url: '/RadMobApp/api',
params:{
action:'invokeService',
serviceName: 'prescriptionService',
methodName: 'sampleClinicalInfo',
username: 'superuser',
password: 'superuser'
},
success: function(xhr) {
var response = Ext.decode(xhr.responseText);
// alert(response.diagnosis);
}
});
}}
]
});
我正在收到像这样的JSON响应
[{"systemReviewInfoMapListSize":1,"diagnosis":"Impaired hearing\nEarache \nEar noise","isClinicalSummaryAvail":"false","isSymptom":"true","isDiagnosis":"true","symptom":"Impaired hearing\nEarache \nEar noise","isSystemReviewInfo":"true"}]
我怎样才能在我的应用程序中阅读...提前致谢。
答案 0 :(得分:3)
您可以尝试以下操作:
var data = Ext.JSON.decode(response.responseText.trim());
假设您的回复是这样的:“id”:123,“name”:“Mac Arthur”那么您应该可以像这样访问它们:
alert("ID: " + data.id + "; Name:" + data.name);
希望这有帮助