jQuery ajaxComplete() 是否检测到 prototypejs ajax 调用?
does jQuery ajaxComplete() detect prototypejs ajax calls?
(function($){
$(document).ready(function(){
$(document).ajaxComplete(function() {
console.log("finished")
});
});
})(jQuery);
这不会在页面上调用原型后触发。
但是这个原型代码是有效的:
Ajax.Responders.register({
onCreate: function() {
console.log("start")
},
onComplete: function() {
console.log("finished")
}
});
之前在页面上加载多个 jquery 库时 ajaxcomplete 存在问题,但现在情况并非如此。
jQuery ajaxComplete() 是否检测原型 ajax 调用?
谢谢!
简答:否
长答案:因为 jQuery 和 PrototypeJS 以不同的方式抽象基本的 XHR 功能,它们以自己的方式跟踪活动 XHR 请求的数量,并触发自己的回调。
例如在 PrototypeJS 中,当 ajax 请求分别开始或完成时,activeRequestCount
递增或递减
Ajax.Responders.register({
onCreate: function() { Ajax.activeRequestCount++ },
onComplete: function() { Ajax.activeRequestCount-- }
});
(function($){
$(document).ready(function(){
$(document).ajaxComplete(function() {
console.log("finished")
});
});
})(jQuery);
这不会在页面上调用原型后触发。
但是这个原型代码是有效的:
Ajax.Responders.register({
onCreate: function() {
console.log("start")
},
onComplete: function() {
console.log("finished")
}
});
之前在页面上加载多个 jquery 库时 ajaxcomplete 存在问题,但现在情况并非如此。
jQuery ajaxComplete() 是否检测原型 ajax 调用?
谢谢!
简答:否
长答案:因为 jQuery 和 PrototypeJS 以不同的方式抽象基本的 XHR 功能,它们以自己的方式跟踪活动 XHR 请求的数量,并触发自己的回调。
例如在 PrototypeJS 中,当 ajax 请求分别开始或完成时,activeRequestCount
递增或递减
Ajax.Responders.register({
onCreate: function() { Ajax.activeRequestCount++ },
onComplete: function() { Ajax.activeRequestCount-- }
});