aboutsummaryrefslogtreecommitdiffstats
path: root/python/risk_insight/static/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'python/risk_insight/static/utils.js')
-rw-r--r--python/risk_insight/static/utils.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/risk_insight/static/utils.js b/python/risk_insight/static/utils.js
new file mode 100644
index 00000000..0b886e8f
--- /dev/null
+++ b/python/risk_insight/static/utils.js
@@ -0,0 +1,22 @@
+function $(s) {
+ return( document.getElementById(s) )
+}
+
+function encode_dict(d){
+ var r = []
+ for(var k in d){
+ r.push(encodeURIComponent(k) + '=' + encodeURIComponent(d[k]));
+ }
+ return r.join('&');
+}
+
+function query(url, params, callback){
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url + '?' + encode_dict(params));
+ xhr.onreadystatechange = function() {
+ if( xhr.readyState === 4){
+ callback(xhr.responseText);
+ }
+ }
+ xhr.send();
+}