Active Client Pages: Simple Document Phase Example Continued
(Page 1 of 4 )
In this sixth part of a twelve-part series on Active Client Pages (ACP), we complete the simple example that illustrates the Document phase of Chrys’s Approach. You need good knowledge of HTML, JavaScript and Perl to understand this part of the series.
Simple Document Phase Example Continued
The page2Doc Content
We are still dealing with the code for the master page. Remember that the content of the page2Doc variable is the downloaded string, which in our simple example is the HTML content (including its JavaScript). This string is actually prepared using Perl. It resides in a Perl file called sendPge2Str.pl in the cgi-bin directory in the server. The Ajax code segment in the master page downloads this string.
Skeleton of the page2Doc String at Server
This is the skeleton of the content of the sendPge2Str.pl file at the server.
$returnStr = qq{
<html>
<head>
</head>
<body>
< -- The HTML elements -- >
<script type= "text/JavaScript">
< -- Ajax Code -- >
< -- Function to develop and load the third page -- >
</script>
</body>
</html>
};
print $returnStr;
There are two Perl statements here. The first one declares the $returnStr variable and assigns the string that has the second page content to it. The other Perl statement is “print $returnStr;”. The statement sends the string to the browser at the Ajax code segment in the master page.
Take a close look at the string declaration. In simplified form, it is
$returnStr = qq{string content};
The double q (qq) precedes the block with the {} brackets. The double q with the {} brackets form what is called the quoting operator in Perl. It is denoted by qq{}. Everything inside the curly brackets is interpreted as a string. So with the qq{} operator, the content in the block can have quotation marks; you do not have to escape any entity in the block.
The content in the qq{} operator above is the HTML document for the second page at the browser. You type everything in the qq{} operator exactly as you would for the HTML document. Do not escape anything. There are two main code segments in the BODY element (in this file). The first one is for the HTML elements. The second one is a JavaScript. This JavaScript has two sub code segments.
Next: The Code Segments >>
More JavaScript Articles
More By Chrysanthus Forcha