[erlang-questions] Ajax in Erlang, anyone?

Tony Garnock-Jones tonyg@REDACTED
Mon Dec 24 13:55:45 CET 2007


Michele Sciabarra wrote:
> Has anyone had experiences and examples about ajax in erlang to share?

I wrote the LShift erlang-jukebox. We started with Yaws, and switched to
built-in inets httpd plus mod_jsonrpc (which comes with rfc4627) for the
second release.

There's a demo AJAX application in the erlang-rfc4627 module, in
test/test_jsonrpc.erl.

Please see
http://www.lshift.net/~tonyg/erlang-rfc4627/doc/mod_jsonrpc.html for
documentation. In particular,
http://www.lshift.net/~tonyg/erlang-rfc4627/doc/mod_jsonrpc.html#running-the-example
shows you how to get the demo running.

Just briefly, JSON-RPC services are regular gen_servers, which are
gen_server:call'd with

  {jsonrpc, MethodNameBinary, _InetsHttpdModData, JsonParameterList}

On the client side, usually something as simple as

  var client = new JsonRpcService("http://localhost:5671/rpc/test",
                                  onReady);

is enough to get access to the methods of the JSON-RPC service.

For more detail, see

http://www.lshift.net/~tonyg/erlang-rfc4627/doc/mod_jsonrpc.html#implementing
http://www.lshift.net/~tonyg/erlang-rfc4627/doc/mod_jsonrpc.html#invoking-js

as well as the code itself, namely

http://www.lshift.net/~tonyg/erlang-rfc4627/test/test_jsonrpc.erl
http://www.lshift.net/~tonyg/erlang-rfc4627/test/server_root/htdocs/test-client.js

Regards,
  Tony
-- 
 [][][] Tony Garnock-Jones     | Mob: +44 (0)7905 974 211
   [][] LShift Ltd             | Tel: +44 (0)20 7729 7060
 []  [] http://www.lshift.net/ | Email: tonyg@REDACTED



More information about the erlang-questions mailing list