我敢打赌,在等待AJAX调用时,这1000个页面中的许多页面实际上并没有阻止UI。相反,他们可能在调用时使用等待屏幕模糊UI,然后在响应处理程序上删除它。
隐藏UI的方法有很多种(你甚至可以使用设置为Modal的jQuery UI对话框,没有转义或关闭按钮),所以我会把这个决定留给你。但代码的布局将是这样的:var someFunction = function () {
// any pre-conditions to the logic
// obscure the UI here
$.ajax({
url: 'ajax/test.html',
success: function(data) {
// handle the response
// show the UI again
},
error: function(data) {
// handle the response
// show the UI again
}
}); }
我确信有多种方法可以实现这种事件顺序,但这是一般的想法。阻止UI从来就不是真正的意图,我认为jQuery 包含该功能比删除它更困难。它意味着异步。