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 ) { if( xhr.status === 200 ) { callback(xhr.responseText) } else if ( xhr.status === 400 ) { console.log(xhr.responseText) } } } xhr.send(); }