Yes, all this is very much correct. I have had the dubious pleasure of doing a fair amount of this sort of thing via the hidden frame.
A couple of important points to be on the look-out for:
- If you are expecting this to function as a "function" call, (i.e. returning a value, and/or halting execution of the calling process (javascript) untill returning) you are pretty much SOL.
The loading of the cgi script in the hidden frame can be thought of as occuring in a different 'thread' if you will.
In order to wait untill the return of the perl function (i.e., wait for the completion of the execution of the cgi, and download/render in your browser) you'd have to go into some horrible hokey javascript which gets vaguley reminiscent of programming in old-school basic with goto-line-numbers and the like... ugh, at the thought.
- in the javascript provided above, (which I understand is off-the-cuff... I merely point this out so that others avoid the potential pitfalls)
<- document.location.href = newurl;
-> parent.**hiddenJSframesNameHere**.document.location.href = newurl;
or else you'll be reloading your own frame which is exactly what you wanted to avoid!
and please, PLEASE use the javascript function escape(...) when constructing that get-string... like:
var newurl = "http...pl?field=" + escape(field) + "&value=" + escape(v
+alue);
(escape performs URI-escaping... for similar stuff in perl, look at URI::Escape)
--a (hopefuly) helpful perl web-junky