I have a simple CGI script that would generate plain text content on demand. For example, http://1.2.3.4/hello.cgi?name=Joe would return Hello Joe!.
How can I read this into a string in Javascript?
name = "Joe";
url = "http://1.2.3.4/hello.cgi?name=" + name;
greeting = loadThis(url);
I’m new to Javascript, so even naive approach (i.e. no need to URL escape…) will be helpful for me 🙂
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:
(Of course, this would not handle names with spaces or special characters correctly, but that’s another story.)