Use the parenscript function ps-inline instead of ps (:a :href (ps-inline (say-hi)) "Say Hi!")
AJAX> (ps-inline (say-hi)) "javascript:sayHi()"
On Sun, Apr 3, 2011 at 1:40 PM, Haris fbogdanovic@xnet.hr wrote:
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!"))))))
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel