# HG changeset patch # User Adam Chlipala # Date 1234715633 18000 # Node ID d80256efc160f08e287c5cb3050447843566eebb # Parent a8704dfc58cfa2d96fb38eaedc37b279ad029cbf Detect AJAX call failures diff -r a8704dfc58cf -r d80256efc160 lib/js/urweb.js --- 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);