2
我知道这是已知的主题,其中一个解决方案是将呼叫更改为同步。 还是不清楚,如果有任何其他方式来做到异步,并获得完整功能的数据? 示例函数在成功函数中创建一个新的资产对象,我想获得完整函数的引用。如何在竞争函数中获取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? – 2012-04-13 23:03:52
即时假设你得到JSON作为服务器的数据 – 2012-04-13 23:05:11
当然是json – 2012-04-13 23:06:38