Mitschu wrote on 10 jul 2007 in comp.lang.javascript
:
Hi Group
I need to parse a response from a cgi script. The response is te
following:
<HTML>UID=834<HTML>
the call for the cgi is http://<server>/cgi-bin/getuid?FILE=uid.html
Now I need the UID in a javascript.
1) call cgi
2) put UID into a variable
How do I have to do that? If I call the cgi the response will be
displayed on the screen but I just need it in the variable.
Thanks for any help.
Use AJAX like technology:
var http = new ActiveXObject("Msxml2.XMLHTTP");
// look for more Cross browser friendly code, this is IE only
function getUrl(url) {
http.open("GET",url,false);
http.send();
return http.responseText;
}
or use a serverside equivalent,
and patch the result in the clientside js code:
var myString = '<%= resultString %>';
<% ' vbscript
Set http = Server.CreateObject("Microsoft.XMLHTTP")
function getUrl(url)
........................
%>
or maybe this works, not tested!:
<script language='jscript' runat='server'>
var http = new ActiveXObject('Microsoft.XMLHTTP');
function getUrl(url) {
http.open("GET",url,false);
http.send();
return http.responseText;
}
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)