read cgi response

M

Mitschu

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.

Michael
 
E

Evertjan.

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,800
Messages
2,569,657
Members
45,416
Latest member
MyraTrotte
Top