Active Client Pages at the Server - The first thing that happens at the server
(Page 2 of 4 )
In ACP you can get data (a string) from the server using either an external JavaScript tag in a JavaScript in a web page at the client, or you can use Ajax.
An example of an external JavaScript tag is:
<script src="xxx.js"></script>
This tag can be in the HEAD element or the BODY element of your web page at the client. The name of the file in the above tag is xxx.js. It is a JavaScript file. If the file is in a directory different from that of the web page, then in place of this file in the above statement, you should have a URL that looks something like this:
http://www.somewebsite.com/subdirectory/xxx.js
The last part of the URL is the file name. The script is downloaded as the browser on the client loads the web page. This JavaScript file simply contains JavaScript statements. The statements may change the content of the present web page or produce another web page at the client’s browser.
If you are getting the data from the server and using Ajax at the client, then you should have something like this in your Ajax code:
xmlHttp.open("GET","http://www.somewebsite.com/cgi-bin/exec.pl",true);
This statement will call the Perl file named exec.pl at the URL of http://www.somewebsite.com/cgi-bin/exec.pl. The exec.pl file is in the cgi-bin directory and it is executable; that is, as soon as it is called, it will be executed at the server.
The purpose of this execution is to get a string of data from the server and send to the client. The content of the string can be used to change the content of the current web page or produce a new web page at the client.
So the first thing that happens at the server is that a JavaScript file is downloaded from it to the client, or a Perl script is executed at the server to send a string to the client; either action depends on what you included in your web page.
Next: Using Perl to send a string to the client >>
More JavaScript Articles
More By Chrysanthus Forcha