comparison 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
comparison
equal deleted inserted replaced
611:a8704dfc58cf 612:d80256efc160
131 131
132 function rc(uri, k) { 132 function rc(uri, k) {
133 var xhr = getXHR(); 133 var xhr = getXHR();
134 134
135 xhr.onreadystatechange = function() { 135 xhr.onreadystatechange = function() {
136 if (xhr.readyState == 4) 136 if (xhr.readyState == 4) {
137 k(xhr.responseText); 137 var isok = false;
138
139 try {
140 if (xhr.status == 200)
141 isok = true;
142 } catch (e) { }
143
144 if (isok)
145 k(xhr.responseText);
146 else
147 alert("Error querying remote server!");
148 }
138 }; 149 };
139 150
140 xhr.open("GET", uri, true); 151 xhr.open("GET", uri, true);
141 xhr.send(null); 152 xhr.send(null);
142 } 153 }