【发布时间】:2013-08-11 10:51:45
【问题描述】:
我有一些 JavaScript:
surveyBusy.show();
$.getJSON(apiUrl + '/' + id)
.done(function (data) {
...
surveyBusy.hide();
})
.fail(function (jqXHR, textStatus, err) {
...
surveyBusy.hide();
});
但是,如果$.getJSON 花费的时间超过n 毫秒数,我只想发出surveyBusy.show();。否则你会闪烁。 getJSON api 上是否有回调可以做到这一点?我看到nothing in the documentation。
【问题讨论】:
-
我刚刚发布了一个答案,它为您提供了 AJAX API 中提供的回调来执行此操作而无需额外的代码。
标签: javascript jquery html ajax