"古い" Dojoの場合、Xhr要求(see Example 6 here)のload
機能に第2引数ioargs
を渡すことができます。このioargs
は、(とりわけ)リクエストのタイムスタンプとステータスコードを提供しました。AMD'ized DojoのXHR応答コード(+タイムスタンプ)を取り出す方法は?
しかし、私はこれを新しい "クリーナー"(および順方向互換性のある)Dojoでどのように達成できますか?
残念ながら、私はcurrent documentationのヒントを見つけることができませんでした。
以下は、上記の「新しい」Dojoの参照先ポートです。しかし、ioargs
は不定となります。
require("dojo/request/xhr", "dojo/dom", "dojo/domReady!",
function(request, dom){
// Look up the node we'll stick the text under.
var targetNode = dom.byId("getLicenseStatus");
// The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.
request.get(
"{{dataUrl}}dojo/LICENSE",
{
handleAs: "text",
preventCache: true
}
).then(
function(data, ioargs){
// FIXME: ioargs is undefined
targetNode.innerHTML = "XHR returned HTTP status: " + ioargs.xhr.status;
},
function(error){
targetNode.innerHTML = "An unexpected error occurred: " + error.response.status + ": " + error.response.text;
}
);
}
);
私はロード機能で利用可能なリクエストのタイムスタンプとステータスコードを持つように変更するには何が必要ですか?
は延期要求によって生成さありません。 get()内部の情報を取得しますか? – djna
'request.get()'は 'promise'オブジェクトを生成します(@Kniganapolkeもそうです)。私は、そこにいくつかの関数定義とプロトタイプのコンストラクタの横にデータを見つけることができません。 –