(function () { "use strict"; function request(querytext, func, errorfunc) { var req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState !== 4) { return; } if (req.status !== 200) { errorfunc(); return; } func(req.responseText); }; req.open("GET",querytext); req.send(); } dologin.onclick = function(e) { request("/login?u="+encodeURIComponent(user.value)+"&p="+encodeURIComponent(pass.value),function(r) { window.location=r;},function() {}); }; }());