the code i am trying to run
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var http = new XMLHttpRequest();
var params = 'frashnum=&action=login&Frm_Logintoken="+results+"&Username=admin&Password=test';
var url = 'http://page/';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onload = function () {
let str = (http.responseText);
alert(str)
let pattern =/\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";/;
let results = console.log(str.match(pattern)[1]);
return results;
}
console.log(results);
http.send(params);
</script>
</body>
</html>
i am trying to return the results variable to use
it in Frm_Logintoken from the params but it says results is not
defined . where clearly it's defined... so i
tried to remove the equals sign before the
function and this part too http.onload =
and it worked but the rest of code didn't ... so is there a way to fix this ?