これは既知のトピックであり、解決策の1つは、呼び出しを同期に変更することです。それでも、それを非同期にして完全な関数でデータを取得する他の方法があるかどうかは私にはわかりませんか?サンプル関数はsuccess関数で新しいアセットオブジェクトを作成し、完全な関数でそれへの参照を取得したいと思います。
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');
}
});
}