[hunchentoot-devel] ht-simple-ajax

Haris fbogdanovic at xnet.hr
Wed Apr 6 12:05:21 UTC 2011


I removed some of the code but it doesn't work anymore.
What's the minimum code I have to add to make it works ?
I don't really get response and callback terms in ajax ?
I'm only interested in ajax now to be able to work with session values with 
javascript.
Now when I click on Say hi link, I only get messagge box with value 
"undefined".

-------------------------------------------------------------------------------

(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 say-hi () (*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
      (:title "ht-simple-ajax demo")
      (princ (generate-prologue *ajax-processor*))
      (:script :type "text/javascript"
       (str
        (ps

        (defun say-hi ()
          (alert (ajax_say_hi)))))))

     (:body
      (:p "Please enter your name: "
          (:input :id "name" :type "text"))
      (:p (:a :href (ps-inline (say-hi)) "Say Hi!"))))))








More information about the Tbnl-devel mailing list