2
これは既知のトピックであり、解決策の1つは同期を呼び出すように変更することです。 非同期処理を行い、完全な関数でデータを取得する他の方法があるかどうかはまだ分かりません。 サンプル関数は、成功関数で新しいアセットオブジェクトを作成し、完全な関数でそのアセットへの参照を取得します。あなたは単にあなたがcomplete
イベントで取得jQXhr
オブジェクトを使用することができ競合機能でjQuery ajaxデータを取得する方法は?
function getPresentation(item) {
$.ajax({
type: "GET",
url: item.Url,
success: function (data) {
assets.push(new asset(item.Type, item.Url, data));
},
complete: function() {
/// How to get here the reference for the newly created asset object?
/// how to alert(asset)?
},
error: function (req, status, error) {
alert('error');
}
});
}
の線に沿ってuが取得している任意の特定のエラーをsomethng
complete(jqXHR, textStatus)
のですか? –imはJSONをサーバーからデータとして取得すると仮定します –
確かにjson –