Javascript: Sample Code

I won’t lie, anytime I need Javascript stuff done, I run to my best friend & fellow programmer, Brandon. We worked on this tonight.. it’s some client side javascript ajaxish action. I’ll be using it for some Remote Assistance stuff I’m doing. I’m putting it here mainly for my future reference on syntax and stuff as I’m a total noob on Javascript fundamentals.

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");"GET", url, 0); xmlhttp.send(); return(xmlhttp.responseText); var xmlhttp = null; }

function printThis() {; document.write(grabVars('workstation')); document.close(); }

One thing…if you attempt to use this code and you try to load up an URL on the Internet (ie. a fully qualified domain name) instead of a local server, you’ll receive the error: msxml3.dll error ‘80070005’ Access Denied. There’s probably a fix but I’m only calling local servers so it’s okay in my case.

Also, I did initially get an IE pop-up that asked me to approve Blocked Content so when I put this out on the Intranet, I’ll have to ask for a GPO modification that enables “Allow active content to run in files on My Computer” (usually found in IE -> Tools -> Advanced Settings). Setting IE parameters in GPO, FYI, is set at Start -> Run -> gpedit.msc -> User Config -> Windows Settings -> Internet Explorer Maintenance -> Security -> Security Zones and Content Rating -> Import Current Settings.

Chrissy is a Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, holds a master's degree in Systems Engineering and is coauthor of Learn dbatools in a Month of Lunches. Chrissy is certified in SQL Server, Linux, SharePoint and network security. You can follow her on Twitter at @cl.

Posted in General