Posted: 02/25/2004, 5:11 AM |
|
I'd like to see remote scripting (like JSRS or MSRS) capabilities in the great product of CCS.
Connecting a database and updating fields, labels or form controls without reloading the entire page is very cool. Modern IDE's or frameworks all contains this feature somehow.
A very good but simple method I saw on the net was below code which I modified a little. This is better than JSRS in a way, since it doesn't use IFRAMEs which causes an annoying click sound every time a content is updating.
function callServer(g_remoteFile) {
var head = document.getElementsByTagName('head').item(0);
var old = document.getElementById('lastLoadedCmds');
if (old) head.removeChild(old);
script = document.createElement('script');
script.src = g_remoteFile;
script.type = 'text/javascript';
script.defer = true;
script.id = 'lastLoadedCmds';
void(head.appendChild(script));
}
It could be called like
<a href="index.html#" onClick="callServer('RemoteFile.pl')">Click here for Perl</a>
<a href="index.html#" onClick="callServer('RemoteFile.php')">Click here for PHP</a>
<a href="index.html#" onClick="callServer('RemoteFile.asp')">Click here for ASP</a>
<span id="Member">Dynamic Text</span>
...
In my position remote file is a perl script which generates JavaScript code. For example
# Javascript header with no cache to avoid caching of old contents
print "Expires: Wednesday, 27-Dec-95 05:29:10 GMT\n";
print "Content-type: text/javascript\n";
print "Pragma: no-cache\n\n";
print " document.getElementById('Member').innerHTML = 'Hello $member'; ";
.Net users have similar features available. It's hard and painful implement this by hand. Only if CCS have this...
P.S. Sorry for my long post. However the page showing similar examples above is closed. I hope web developers can make use of this if they haven't been used yet.
|