Re: [Cppcms-users] Interface with javascript
Brought to you by:
artyom-beilis
|
From: Nazım C. B. <naz...@ne...> - 2017-07-15 12:59:48
|
Hi,
In such cases, I usually prefer to use technique which is also central
to Apache's Tapestry project. Basic structure is follows:
* Boilerplate web page is generated by CppCMS as usual.
* Boilerplate web page is using require.js.
* On page load, require.js is loading web application's entry point.
* From the entry point, my own Javascript module do following:
o Make an Ajax requests to web app via JSON-RPC.
o On the server side, application is responding to requests with
|cppcms::rpc::json_rpc_server.|
o Javascript handles the server's response and apply changes.
o In my case, changes are either loading additional require.js
modules, or changing already existing DOM elements and their
content on the page.
* For things like user notification, I prefer to employ Server-Side
Events; where initial registration for the events are performed from
the Javascript module loaded by require.js.
For JSON-RPC, please see
http://cppcms.com/wikipp/en/page/cppcms_1x_chat_json_rpc. For
Server-Side Events, please see http://blog.cppcms.com/post/107.
Out of box, CppCMS doesn't provide any way to glue browser events and
DOM to C++ objects. If you do not already know about, I highly suggest
to take a quick look at tapestry.apache.org for getting an idea about
how deep the rabbit hole may be :)
Hope helps.
Regards,
Nazim Can.
On 15/07/17 15:23, jupiter wrote:
> Hi,
>
> I am still learning the structure of the cppcms, most of examples and
> tutorials are calling cppcms generate html page. One thing I am not
> clear is how to make an interface between C++ and javascript with AJAX
> capability, the C++ feeds json to javascript which renders ajax style
> web page. Appreciate any advice.
>
> Thank you,
>
> Kind regards,
>
> - j
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
|