I'm trying to use WinHTTP in JScript (ES3) to a-synchronously retrieve the responsetext of an internal site that requites SSO log-on. The below works (I've replaced the url with "http://www.google.com/"), but I don't know how to get a callback or check when WinHTTP is done. I cannot use XMLHTTP as that won't log on automatically and stays on readystate 1, and it seems that WinHTTP doesn't support 'onreadystatechange'. As I need to use ES3/JScript, I cannot use JQuery or other plug-ins and need it to be 'vanilla'.
Here's what I have now.
var a = '';
var x = new ActiveXObject('WinHTTP.WinHTTPRequest.5.1'), method = 'GET', url = 'http://www.google.com/';"
x.SetAutoLogonPolicy(0);
x.open(method, url, true);
x.send();
So this succesfully returns the request, but I don't know how to trigger it so that on completion it will put the responsetext into variable 'a'. When using XMLHTTP it would work like below, but as mentioned, that won't work with my SSO site:
Working for google, but not for my internal site - and the 'onreadystatechange' doesn't work with winhttp...
var a = '';
var x = new ActiveXObject('Microsoft.XMLHTTP'), method = 'GET', url = 'https://www.google.com/';
x.open(method, url, true);")
x.onreadystatechange = function () {if(x.readyState === 4 && x.status === 200){a = x.responsetext;}};
x.send();
I would appreciate guidance! Thank you