From 75f2366a7dd8f91cc6e959519455c431e316a0ee Mon Sep 17 00:00:00 2001 From: tdro Date: Tue, 12 Dec 2023 19:42:00 -0500 Subject: static/js/infinitescroll: Wider fallback --- static/js/infinitescroll.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'static') diff --git a/static/js/infinitescroll.ts b/static/js/infinitescroll.ts index 8d6a57f..bef477b 100644 --- a/static/js/infinitescroll.ts +++ b/static/js/infinitescroll.ts @@ -12,11 +12,11 @@ function fetch(url, method, callback, fallback) { const http = new XMLHttpRequest(); http.onreadystatechange = function () { - if (callback && http.readyState === 4 && http.status === 200) { - callback(http); + if (callback && http.readyState === 4) { + if (http.status === 200) callback(http); + else fallback(http); } }; - http.addEventListener("error", fallback); http.open(method, url); http.send(); return http; @@ -66,8 +66,8 @@ console.log("INFO: Fetch", next.href, items); - }, function (event) { - console.warn("WARNING: Switching to native pagination", event); + }, function (http) { + console.warn("WARNING: Switching to native pagination", http); main.insertAdjacentElement("afterend", pagination); abort = true; }); -- cgit v1.2.3