diff lib/js/urweb.js @ 612:d80256efc160

Detect AJAX call failures
author Adam Chlipala <adamc@hcoop.net>
date Sun, 15 Feb 2009 11:33:53 -0500
parents 56aaa1941dad
children c5991cdb0c4b
line wrap: on
line diff
--- a/lib/js/urweb.js	Sun Feb 15 11:24:16 2009 -0500
+++ b/lib/js/urweb.js	Sun Feb 15 11:33:53 2009 -0500
@@ -133,8 +133,19 @@
   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);