aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorzrose584 <57181548+zrose584@users.noreply.github.com>2020-10-09 18:49:50 +0200
committerzrose584 <57181548+zrose584@users.noreply.github.com>2020-10-09 18:49:50 +0200
commit205665f138afa3e6b1242bbe5dd433c0991f5fe6 (patch)
tree1cb38abd4a12cf1eae1a71dbacb7a237f7ff8797 /youtube
parentdebc11931fe1102f17852fd082d0dac50d477ce9 (diff)
downloadyt-local-205665f138afa3e6b1242bbe5dd433c0991f5fe6.tar.lz
yt-local-205665f138afa3e6b1242bbe5dd433c0991f5fe6.tar.xz
yt-local-205665f138afa3e6b1242bbe5dd433c0991f5fe6.zip
doXhr: check xhr.status
Diffstat (limited to 'youtube')
-rw-r--r--youtube/static/js/common.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js
index 40bc132..2997f61 100644
--- a/youtube/static/js/common.js
+++ b/youtube/static/js/common.js
@@ -40,7 +40,11 @@ function getDefaultTranscriptTrackIdx() {
function doXhr(url, callback=null) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
- xhr.onload = (e) => {callback(e.currentTarget.response)};
+ xhr.onload = (e) => {
+ let ok = xhr.status >= 200 && xhr.status < 300;
+ if (ok) callback(e.currentTarget.response);
+ else alert(`${xhr.responseURL} status code: ${xhr.status}`);
+ }
xhr.send();
return xhr;
}