View Full Version : executing CGI from Javascript function

08-22-2002, 04:25 PM
Is there a way for javascript to retrieve a string a CGI script returns/prints?
My script is on http://www.dubfilter.com/cgi-bin/album/dirlist.cgi
the execution command is http://www.dubfilter.com/cgi-bin/album/dirlist.cgi?filedir=../../album/display and my html file with the javascript in the header is at http://album.dubfilter.com/new/index.shtml (made it shtml in case the only way to do this is using the SSI #exec command).
any help will be appreciated. i have searched forums and internet reference guides, with absolutely no luck. i hope there is a way to do this.
thanks in advance.

08-22-2002, 10:48 PM
i know a little about this, but i've no experience with server side, so i might not get it exactly right.

you can make a server side script run by calling it as an external javascript file.

<script language="javascript" src="http://www.dubfilter.com/cgi-bin/album/dirlist.cgi?filedir=../../album/display"></script>

in order to get javascript to be able to use the results, you just have to make sure that the results that are returned are in the form of javascript. i think the mimetype for javascript is text/javascript, but i'm not positive of that.

hope that helps.

08-22-2002, 10:57 PM
It sounds to me like what you want is for javascript to read the query string, which you can retrieve using location.search

Have a look at this thread http://www.codingforums.com/showthread.php?s=&threadid=4555 for a more sophisticated function to retrieve the name/value pairs