| Author |
Message |
|
| dmitriid |
Posted: Mon Feb 18, 2008 9:35 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
A friend of mine has approached me with the following question: how do
you handle Ajax in Erlang/ErlyWeb/Mochiweb/Yaws?
He likes the approach that GWT has - you only have to worry about
necessary functions once, the framework generates all the necessary
boilerplate code for you.
By boilerplate I mean the code that implements the necessary
client-server interfaces and protocols that you don't need to check
twice (once on the server and once on the client). You also don't have
to worry about changing things on one side and breaking things on the
other side, thus effectively halving the time you need to spend on
testing and debugging.
How do you add ajax to your apps and has anybody considered a GWT approach?
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| tobbe |
Posted: Mon Feb 18, 2008 10:53 am |
|
|
|
User
Joined: 19 Jan 2005
Posts: 274
Location: Stockholm, Sweden
|
Hi,
It would be intereseting to hear what others have
taken as an approach to this.
Here is a simple example of things I've done.
And since it is very simple, I've not bothered
with any fancy lib, hiding the interface beetween
the server and client.
I'm using jQuery, and in this example, also a jQuery
plugin for drawing graphs.
....some HTML and Javascript...
<script language="javascript" type="text/javascript">
function redraw(what) {
$.getJSON("/graph_data.yaws",
{'op': "redraw", 'what': what},
function(x) {
do_redraw(what, x)
});
}
function do_redraw(what, x) {
$.plot($(what), [ x.d2 ]);
}
</script>
<button id="draw" onclick="redraw('#placeholder')">Redraw!</button>
............
.....some (simplified) Erlang code....
out(A) ->
L = yaws_api:parse_query(A),
dispatch(lkup(L, "op", false), A, L).
dispatch("redraw", A, L) -> redraw(A, L);
redraw(_A, _L) ->
{A1,A2,A3} = now(),
random:seed(A1, A2, A3),
J = json:encode({struct,
[{"d2", {array, [{array, [1,random:uniform(10)]},
{array, [2,random:uniform(10)]},
{array, [4,random:uniform(10)]},
{array,[5,random:uniform(10)]}
]}}]}),
return_json(J).
return_json(Json) ->
{content, "application/json; charset=iso-8859-1", Json}.
................
Cheers, Tobbe
Dmitrii 'Mamut' Dimandt wrote:
> A friend of mine has approached me with the following question: how do
> you handle Ajax in Erlang/ErlyWeb/Mochiweb/Yaws?
>
> He likes the approach that GWT has - you only have to worry about
> necessary functions once, the framework generates all the necessary
> boilerplate code for you.
>
> By boilerplate I mean the code that implements the necessary
> client-server interfaces and protocols that you don't need to check
> twice (once on the server and once on the client). You also don't have
> to worry about changing things on one side and breaking things on the
> other side, thus effectively halving the time you need to spend on
> testing and debugging.
>
> How do you add ajax to your apps and has anybody considered a GWT approach?
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|