Based on this FAQ on JavaScriper.net, I have found solution that works for me. However, the called script must be on the same machine as the caller, otherwise I get security errors from browsers.
Apparently this is what @Makkes mentioned. However, I'm perfectly happy with having the hello.cgi on the same machine for now.
Here is the code:
function loadThis(localuri) {
var oRequest = new XMLHttpRequest();
var sURL = 'http://'
+ self.location.hostname
+ localuri;
oRequest.open('GET',sURL,false);
oRequest.setRequestHeader('User-Agent',navigator.userAgent);
oRequest.send(null);
if (oRequest.status==200) return(oRequest.responseText);
else alert('Error executing XMLHttpRequest call!');
}
name = "Joe";
localuri = "/hello.cgi?name=" + name;
greeting = loadThis(localuri);
(Of course, this would not handle names with spaces or special characters correctly, but that's another story.)