我们做的一个jQuery控件出了点问题。假设您有一个下拉列表,允许您输入要查找的项目的ID,当您在文本框中按enter键或失去焦点时,它会通过jQuery验证您输入的ID是否正确,如果不正确,则会显示警告。
问题是,当普通用户在其中输入无效值并因按下submit按钮而失去焦点时,jQuery post将在表单的提交被发送后返回。
有没有什么方法可以让我检查jQuery是否有异步请求处理,这样我就不允许提交表单了?
发布于 2011-10-20 03:11:40
$.active
返回活动Ajax请求的数量。
更多信息here
发布于 2011-12-28 11:21:04
$(function () {
function checkPendingRequest() {
if ($.active > 0) {
window.setTimeout(checkPendingRequest, 1000);
//Mostrar peticiones pendientes ejemplo: $("#control").val("Peticiones pendientes" + $.active);
}
else {
alert("No hay peticiones pendientes");
}
};
window.setTimeout(checkPendingRequest, 1000);
});
https://stackoverflow.com/questions/1822913
复制相似问题