[hunchentoot-devel] ht-simple-ajax

Lou Vanek lou.vanek at gmail.com
Wed Apr 6 18:32:40 UTC 2011


I know this isn't exactly what you've requested, but it does show how
to get a session value and display it in the browser. It's been tested
in the latest Chrome, IE, and Firefox, and uses Hunchentoot.
http://paste.lisp.org/display/121215
Sometimes simpler is better.


On Wed, Apr 6, 2011 at 10:21 AM, Haris <fbogdanovic at xnet.hr> wrote:
> Here I changed the function names to reflect the code:
>
> -------------------------------------------------------------------------------
>
> (defpackage :sessions (:use :cl :hunchentoot :cl-who :parenscript
> :ht-simple-ajax))
>
> (in-package sessions)
>
> (setf *access-log-pathname* "c:/lisp/hunchentoot-log/access.log")
> (setf *message-log-pathname* "c:/lisp/hunchentoot-log/message.log")
>
> (setf *js-string-delimiter* #\")
>
>
> (defparameter *ajax-processor*
>  (make-instance 'ajax-processor :server-uri "/ajax"))
>
> (push (create-ajax-dispatcher *ajax-processor*) *dispatch-table*)
>
> (defun-ajax show-x () (*ajax-processor*)
>  (write-to-string (incf (session-value 'x))))
>
>
> (define-easy-handler (main-page :uri "/") ()
>  (start-session)
>  (setf (session-value 'x) 10)
>  (with-html-output-to-string (*standard-output* nil :prologue t :indent t)
>    (:html :xmlns "http://www.w3.org/1999/xhtml"
>     (:head
>      (princ (generate-prologue *ajax-processor*))
>      (:script :type "text/javascript"
>       (str
>        (ps
>
>        (defun show-x ()
>          (alert (ajax_show_x))))))
>
>     (:body
>      (:p (:a :href (ps-inline (show-x)) "Show X"))))))
>
>
>
>
>
>
>
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel
>




More information about the Tbnl-devel mailing list