[hunchentoot-devel] ht-simple-ajax

Haris fbogdanovic at xnet.hr
Sun Apr 3 17:40:39 UTC 2011


I changed the code. When I click on say-hi link it goes to:
http://localhost/sayHi();
and the page says: Hunchentoot Default page.
Where is the problem now ?

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

(defpackage :ajax (:use :cl :hunchentoot :cl-who :parenscript 
:ht-simple-ajax))
(in-package ajax)

(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 (name) (*ajax-processor*)
  (concatenate 'string "Hi " name))

(define-easy-handler (main-page :uri "/") ()
  (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 callback (response)
            (alert (@ response first-child first-child node-value)))

        (defun say-hi ()
          (ajax_say_hi (chain document (get-element-by-id "name") value) 
callback))))))

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





More information about the Tbnl-devel mailing list