[MAKR] 2006/10/22: I've looked into [AJAX] and what it takes to use it with Tcl on the server's side. To get started I used a good example for [PHP] from [http://www.xml.com/pub/a/2005/02/09/xml-http-request.html]. It's really easy. Most of the code involved is [Javascript]. But have a look for yourself ...
#!/usr/local/ActiveTcl/bin/tclsh8.4
package require ncgi
# possible content types in this example
set ctx "text/xml"
set cth "text/html"
# Check whether the name is used already
# fixed list for simplicity: Alice, Bob
proc nameInUse {q} {
switch -- [string tolower $q] {
alice - bob {return 1}
default {return 0}
}
}
::ncgi::parse
if {[::ncgi::exists q]} {
# Background operation: check query
::ncgi::header $ctx
puts "
checkName[nameInUse [::ncgi::value q]]"
} else {
# Initial call: build page
::ncgi::header $cth
puts ""
puts ""
puts ""
puts "
This name is in use, please try another.
"
}
Execute this as CGI script. Tried with IE 6.0 and Firefox 1.5...
----