Mercurial > urweb
diff lib/js/urweb.js @ 609:56aaa1941dad
First gimpy RPC
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 15 Feb 2009 10:32:50 -0500 |
parents | 5145181b02fa |
children | d80256efc160 |
line wrap: on
line diff
--- a/lib/js/urweb.js Sun Feb 15 09:27:36 2009 -0500 +++ b/lib/js/urweb.js Sun Feb 15 10:32:50 2009 -0500 @@ -111,3 +111,32 @@ return closures[n](); } + +function getXHR() +{ + try { + return new XMLHttpRequest(); + } catch (e) { + try { + return new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + return new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + throw "Your browser doesn't seem to support AJAX."; + } + } + } +} + +function rc(uri, k) { + var xhr = getXHR(); + + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) + k(xhr.responseText); + }; + + xhr.open("GET", uri, true); + xhr.send(null); +}