我是新來的ext Js。解碼Ajax響應
我有一個ajax調用。我可以看到警報上的響應文本,但下一行(假定解碼responseText)不會在警報框中產生任何結果。
我的功能是這樣的:
function openToRecipients()
{
Ext.Ajax.request({
url: "Redirector?id=ClinicalInitiateForm&wfid=CLINICALONGOINGWFINITIATE",
method: 'POST',
success: function(response, opts)
{
alert(response.responseText);
var dataCurrent = Ext.util.JSON.decode(response.responseText);
alert(dataCurrent);
var jsonStr = dataCurrent.cData;
recipientJsonResponse = dataCurrent.dataGrid;
var myObject = eval('(' + jsonStr + ')');
gridStore = new Ext.data.JsonStore({
id : 'gridStore',
autoLoad : true,
data : myObject,
root : 'data',
fields:['NAME',
'CLIENT',
'DESCRIPTION'
],
listeners :{
load : gridDisplay
}
});
},
failure: function(response, opts) {
alert("fail");
}
});
}
這是coverting串
"formFields" : [ {
"id" : "NAME",
"set" : "",
"label" : "Name",
"dataType" : "string",
"editType" : "static",
"clientConfig" : "",
"hide" : "False",
"required" : "",
"mask" : "",
"maxValue" : "",
"maxLength" : "",
"minValue" : "",
"value" : "",
"showIf" : "",
"options" : "",
"prePopulate" : "",
"shortForm" : "",
"comments" : "",
"optionsValue" : "",
"currentValue" : "",
"disabled" : "",
"qTip" : "",
"hover" : ""
}, {
"id" : "CLIENT",
"set" : "",
"label" : "Client",
"dataType" : "string",
"editType" : "static",
"clientConfig" : "",
"hide" : "False",
"required" : "",
"mask" : "",
"maxValue" : "",
"maxLength" : "",
"minValue" : "",
"value" : "",
"showIf" : "",
"options" : "",
"prePopulate" : "",
"shortForm" : "",
"comments" : "",
"optionsValue" : "",
"currentValue" : "",
"disabled" : "",
"qTip" : "",
"hover" : ""
}, {
"id" : "DESCRIPTION",
"set" : "",
"label" : "Description",
"dataType" : "string",
"editType" : "static",
"clientConfig" : "",
"hide" : "False",
"required" : "",
"mask" : "",
"maxValue" : "",
"maxLength" : "",
"minValue" : "",
"value" : "",
"showIf" : "",
"options" : "",
"prePopulate" : "",
"shortForm" : "",
"comments" : "",
"optionsValue" : "",
"currentValue" : "",
"disabled" : "",
"qTip" : "",
"hover" : ""
} ],
後,我的JSON和這是我的數據
{'data':[{"NAME":"Shan","CLIENT":"CSC","DESCRIPTION":"Computer science"}]}
我怎麼能有這樣的數據在我的網格中
答案是有效的Json?請提供,以便我們可以幫助回答這個問題。 – Brian 2012-07-18 12:39:26
你是否想知道我的json是否有效?是的,這是 – 2012-07-18 12:41:57
重點是要看看,否則我們無法幫助。我在上面的代碼中看不到任何明顯的錯誤,所以不可能知道什麼是錯的。所以發佈JSON響應。 – Brian 2012-07-18 12:50:44