I'm having a bit of trouble trying to understand how WARP could potentially interact with the client-side. If I were to build my server-side via WARP, and had a Javascript client-side. Could I hypothetically use AJAX as the bridge between the client side and server-side?
Asked
Active
Viewed 1,096 times
2
-
I posted a related Q&A today, maybe you want to have [a look](http://stackoverflow.com/a/22183490/2597135) – Uli Köhler Mar 04 '14 at 21:38
1 Answers
6
Yes. AJAX doesn't need to know anything about your server to work. All it needs to do is request something at a url, and get a response.
For example, suppose you are using jquery. Your Ajax request could look like:
$.ajax({
url: "/hello",
}).done(function() {
$(this).addClass("done");
});
This is requesting something at url /hello
. Then your Yesod app needs to serve something at /hello
:
mkYesod "yourapp" [parseRoutes|
/hello HelloR GET
|]
getHomeR :: Handler RepHtml
getHelloR = defaultLayout [whamlet|Hello!|]
(I haven't used Yesod, so I can't claim that that code is accurate).
Since WARP is a WAI handler, you can run any WAI application on it. Here's another example, this time using scotty:
main = scotty 3000 $ do
get "/hello" $ html "Hello!"

Vlad the Impala
- 15,572
- 16
- 81
- 124
-
Thanks for the response. This has all been over my head for the last week or so. You made it really clear and understanding to me. Thank you! – George Vasels Apr 02 '12 at 19:50