To add AJAX functionalities in your TCL web scripts:
- Use SajaxTCL, the TCL port of the popular Sajax library
- See the Simple AJAX Example to develop your own implementation
escargo 26 Sep 2005 - Is there infrastructure in place to use Tcl in the same way as Javascript? It seems like Tcl (using the Tcl/Tk Tclet Plugin) could accomplish much the same thing. Would it be necessary to use the XMLHttpRequest object?It would be nice to be able to demonstrate AJAX-like behavior in Tcl.schlenk 26 Sep 2005 - With the Tcl Plugin you don't need all the XML mumbo jumbo, just open a socket back to the original server or do some http requests via the http package to get the dynamic info you want.Doing AJAX with Tcl is a matter of ripping of the JavaScript part for the browser side and doing some XML processing on the server side, be it with Aolserver, Tclhttpd, Rivet or one of the other things. Not too hard to do (I have a XUL based JavaScript app as a Mozilla browser sidebar talking to tclhttpd via Mozillas Javascript SOAP-API, very similar stuff)(escargo - Could you clarify what you mean by "ripping of the JavaScript part"? Perhaps, "ripping out"? If it is ripping out, do you know what you would replace it with? The XMLHttpRequest object seems to be a JavaScript (or ActiveX) thing. I don't know if we have (or need) an equivalent.schlenk - With the Tcl Plugin you do not need this XMLHttpRequest object, just use the http package with the -command option and fetch pages from the server the plugin code is loaded from and update the things displayed in the plugin accordingly. Basically AJAX is just a limited RPC mechanism for JavaScript which runs in a browser while displaying a web page. All those AJAX frameworks just provide a) a server to answer XMLHttpRequests, b) JavaScript code to issue XMLHttpRequest with minimal coding, c) some HTML generation support to plug things together. Part a) could probably done with tclhttpd and tdom quite fast, part b) can be adapted directly from other frameworks, part c) would be an extension for something like tcllib::html or Rivet to be useful.))LES same day: open a socket and leave it open for as long as the browser window is open? For each visitor? Then I suppose a few thousand open sockets could accumulate in just a few minutes if the site is popular enough. I imagine the impact on the server's performance.schlenk it really depends. Having a socket open would mean the server can push information to the client. Doing HTTP means polling by the client. So just open sockets do no real harm (some small amount of memory), but the limited amount of ports will eventuell hit). As there is no simple way to increase the number of available ports but it is simpler to increase the computing power of the server so it can serve many more empty polling requests its probably the way to go. Especially as most AJAX apps are inherently: user sends data to server and gets update and not something like stock tickers etc. where the server would like to push data. Its more an RPC thing.TP See Comet, an Ajax technique that keeps sockets to browsers open: [1] [2] [3]Also: google for the terms "reverse Ajax" and "long polling" for ways to overcome latency and overhead in push scenarios -jcw[When CL makes the time, he'll complement the descriptions above with a security-oriented one 'bout how Tcl does more than Ajax, but mostly has a different security profile. Michael correctly highlights the JavaScript-Java restriction to connections back to original server (or ...).]
See also:
- JSON
- Using Tcl to write WWW client side applications within the WWW browser
- Simple AJAX Example
- scriptaculous
- Æjaks - Tcl-based, Tk-like Ajax development.
- SajaxTCL
- Wibble supports Ajax