私のアプリケーションには、バインディングまたはform.getForm()。loadRecord()メソッドを使用して入力されたフォームがあります。jsonレスポンスajaxリクエストから直接データを取得する方法
このフォームには、Ext.Ajax.requestの応答から直接入力する2つのフィールドが動的に追加されます。
json応答ajaxリクエストから直接データを取得する最も良い方法は何ですか?
Ext.Ajax.request({
url: 'php/read',
method: 'POST',
params: {
'myId': myId,
},
success: function (conn, response, options, eOpts) {
var one = //get directly from request response (json) //????
},
failure: function (conn, response, options, eOpts) {
}
});
var one = //get directly from request response (json) //???
var two = ...
Ext.ComponentQuery.query('#fieldOne')[0].setValue(one);
Ext.ComponentQuery.query('#fieldTwo')[0].setValue(two);
。応答データを取得するには
編集
//json
data:{
one: "A",
two: "B"
}
:
success: function (response, options) {
var resp = Ext.decode(response.responseText);
//or
var resp2 = response.responseText;
}
RESPで、私が得る:
Object
success: Object
data: Array[1]
RESP2で私が取得:
{"success":{"success":true},"data":[{"one":"A","two":"B"}]}
これは次のようにデータにアクセスすることになった。
resp.one
//or
resp2.one
//or
resp.data.one
しかし、それは未定義 'を返します。
「1つの値」を得るには何が欠けていますか?
'data'は配列です。 'resp.data [0] .one'です。 –
ありがとうエヴァン。あなたのソリューションは私の問題を解決します。 – josei