From e7fdb6e0f6ab265f3cd850d3663a91b531de8ba8 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 15 Feb 2009 11:33:53 -0500 Subject: Detect AJAX call failures --- lib/js/urweb.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/js/urweb.js') diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 9dd4dbbe..bfca94a4 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -133,8 +133,19 @@ function rc(uri, k) { var xhr = getXHR(); xhr.onreadystatechange = function() { - if (xhr.readyState == 4) - k(xhr.responseText); + if (xhr.readyState == 4) { + var isok = false; + + try { + if (xhr.status == 200) + isok = true; + } catch (e) { } + + if (isok) + k(xhr.responseText); + else + alert("Error querying remote server!"); + } }; xhr.open("GET", uri, true); -- cgit v1.2.3