//Javascript
function request() {
trace('start');
new Ajax.Request('http://localhost:3000/test', {
method: 'GET',
crossSite: true,
onLoading: function(transport) {
trace('onLoading' );
},
onComplete: function(transport) {
trace('onSuccess');
trace('The message is '+message);
},
onFailure: function() {
trace('onFailure');
}
});
}
//ruby
class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
response.start(200) do |head,out|
head["Content-Type"] = "text/javascript"
out.write("var message = 'hello';\n")
end
end
end
h = Mongrel::HttpServer.new("127.0.0.1", "3000")
h.register("/test", SimpleHandler.new)
h.run.join
|