Edit:
if ('abort' in $(this).data('xhr') ) $(this).data('xhr').abort();
at
if ($(this).data('xhr') && $(this).data('xhr').abort) {
$(this).data('xhr').abort();
}
The problem was simply checking if the object has an xhrelement. By default, it does not exist, therefore it undefined, and you asked the JS engine to find the element in the undefinedinformation causing the error.
, , , .data('xhr'), JS undefined false, , data('xhr') abort.
, , -, AJAX, XHR :
if($(this).data('timer')) {
clearTimeout($(this).data('timer'));
}
var timer = setTimeout(function() {
$.ajax({
url : '/files/tags_autocomplete.php',
dataType : 'JSON',
success : function (tags) {
$("ul").html(tags.output);
}
});
}, 500);
$(this).data('timer', timer);
( ):
if(window.autocompleteTimer) {
clearTimeout(window.autocompleteTimer);
}
window.autocompleteTimer = setTimeout(function() {
$.ajax({
url : '/files/tags_autocomplete.php',
dataType : 'JSON',
success : function (tags) {
$("ul").html(tags.output);
}
});
}, 500);