Re: calling functions from cgi
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: calling functions from cgi

From: RobG <rgqld@iinet.net.au>
Date: Wed Feb 01 2006 - 00:47:34 CET

Tony Rice wrote:
> RobG <rgqld@iinet.net.au> wrote in news:zvBDf.251$Nv4.46029
> @news.optus.net.au:
>
>
>>That sounds like you are trying to access elements before the page has
>>created them, either onload or after the AJAX stuff.
>>
>>Code snippet? URL?
>
>
> I'm using jah (http://microformats.org/wiki/rest/ahah) to load URLs inline
> dynamically. The perl script looks like this:
>
> my $ajaxcall="jah('myotherscript.cgi?myarg=arg', 'contentdiv')";
> if (param('myparam')){
> print "<script type=\"text/javascript\">$ajaxcall</script>\n";
>
> }else{
> print a({href=>"javascript:$ajaxcall"}, 'click to load');
> }
> print "<div id='contentdiv'></div>\n";

Don't post server code, post what your client gets - this is a
JavaScript news group, not Perl :-)

What content is written to the script element? What is written as the
value of the A element's href attribute? What is the surrounding HTML?

I have no idea what is ending up in your A element attributes, so it's
hard to help. Use view source on the client to get the actual HTML that
is delivered to your page (a minimal test case will do).

> The goal is to have the content loaded inline automatically if the
> 'myparam' is passed in the query string and make it loadable inline by
> clicking the link.
>
>
> I'm getting the following errors:
>
> document.getElementById(target) has no properties

The value of 'target' should be the ID of an element on your page. If
the page hasn't finished loading (unlikely), or the ID doesn't exist
(much more likely), then you will get the error you get.

The 'ahah' code does not test to see if features are supported, nor does
it check to see if document.getElementById(target) returns anything
useful before trying to access its innerHTML property.

>
> and
>
> href has no properties
>
> These are both coming from the ahah code. What I dont get is what is
> special about the click. Either way it's accessing the document object so
> it's not like the click is providing an object.

The click runs the script that is in the A element's href attribute. If
you show the client HTML, we can see what is actually in the href attribute.

-- 
Rob
Received on Tue Feb 7 21:29:24 2006