Reputation: 41
I'm using jQuery version 1.5.1 and this isn't working for me:
$(window).ajaxComplete(function() {
console.log('hello');
});
but this is:
$(document).ajaxComplete(function() {
console.log('hello');
});
Why can't I attach the event handler to $(window)
?
Note: this code is working with jQuery v1.3.2 but not with v1.5.1
Upvotes: 4
Views: 2073
Reputation: 23283
Probably because window
is
1.) Not an element
2.) Somewhat 'protected' by the browser's js engine
3.) a bad idea when looking for something to attach an AJAX event to
Why can't you use document
or an element instead?
Upvotes: 5