hoploncljs-ajax

How to do a Hoplon CLJS Server or AJAX Call


I am using Hoplon to create a fairly simple site and an stuck on the AJAX part. In the past I have used Castra as the backend but since it is no longer maintained I have switched to a normal LuminusWeb backend. I am in need of making a call to the server in which I will the server and then wait for a response. I know how to do it on the server side but I can't seem to find any information about how to do it on the Hoplon Client side.

How can I send a request to the server using an AJAX call?

I know how to do it in jQuery and assume, possibly wrongly, there is something similar to $.POST in Hoplon.

Cheers


Solution

  • The best way to solve this AJAX problem that I found is to use the library 'cljs-http' and then you can make an synchronous request using a call such as:

    (http/post "http://localhost:8080/" {:with-credentials? false})
    

    Then, on the cljs-http GitHub README.md it gives plenty of examples so you can then do asynchronous in Hoplon.