普通のやりかた
私たちの手元にあるのは、HTTPサーバと、CGIと、Javascriptと、Ajaxだ。
- HTTPサーバを立てる。
- CGIを Bigloo (Scheme処理系) で書いて設置。例えばURLは、http://hoge.com/serverdate.cgi
- HTMLを書く。Ajax なら、 prototype.js を使おう。こんな感じ。
<html> <head> <script src="prototype.js" type="text/javascript"></script> <script type="text/javascript"><!-- function ajax() { var url = 'http://hoge.com/serverdate.cgi'; var myAjax = new Ajax.Request( url, { method: 'get', onComplete: showResponse }); } function showResponse(originalRequest) { //alert returned XML alert(originalRequest.responseText); } // --></script> </head> <body> <button onclick="ajax()" value="Server time"/> </body> </html>
できあがり。