Michael Neumann
11/21/2007 4:54:00 PM
Miki Vz schrieb:
> :'(. Ok then, thanx.
Keep smiling :)
AJAX can be so simple with just Mongrel (no Rails required at all!!!!!):
require 'rubygems'
require 'mongrel'
require 'json'
class AjaxHandler < Mongrel::HttpHandler
def process(req, res)
res.start(200) do |header, out|
out << JSON.dump({"Hello" => "AJAX!"})
end
end
end
Mongrel::Configurator.new :host => '127.0.0.1' do
listener :port => 5000 do
uri '/', :handler => AjaxHandler.new
run
join
end
end
All you need are the 'json' and 'mongrel' gems. In your HTML page simply use
jquery (www.jquery.com), and make a AJAX call to the server. That's so easy!
Regards,
Michael