I would like to create a server an Erlang capable of receiving and sending AJAX messages. Is there a module that provides this functionality?
问题:
回答1:
Well, i would not call it a module, perhaps a "library" would be a better description. check out these: Mochiweb, Webmachine and Nitrogen -- the master of Event Driven Web Apps.
What you need is RESTFUL services in Erlang. You want to be able to initiate HTTP GET or POST requests from your Ajax, say with JSON encoded Data and you expect to get back JSON encoded responses. Mochiweb has a good JSON parser and its Light Weight. The heavy duty Web server called Yaws is very capable of doing what you want. There is a good tutorial about RESTFUL services with Yaws. The most wonderful thing about all these is that you can use all or several of them together in the same web App (but you need some experience to do so, it aint very obvious for starters!)
However, you will need to get a grip of Erlang Concepts of doing things and you will then find all these frameworks very easy. These are not the only ones you can look into, there is ErlyWeb, Erlang Web and so many upcoming libraries.
Am sure you will find any one of these useful.
回答2:
Well, it really depends on what you mean by "Ajax messages". Ajax requires nothing more than regular pages do. Just send back the requested data instead of a new page.
If you want a nice framework for web apps in Erlang, check out Nitrogen.
回答3:
AJAX as in "asynchronous requests within browser" is client-side technology that allows doing additional HTTP requests without reloading page.
Any HTTP server is capable of sending and receiving AJAX messages because those are just HTTP requests.
You can use any debugging tool(firebug, chrome javascript console, etc) to check that.