Re: [Cppcms-users] Instantiate JsonRPC with dynamic URL path
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2014-07-22 07:54:04
|
Show the full HTML... Have you loaded the JsonRPC script from the contrib section - the script that actually defines the JsonRPC object? Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: CN <cn...@fa...> >To: cpp...@li... >Sent: Tuesday, July 22, 2014 8:50 AM >Subject: Re: [Cppcms-users] Instantiate JsonRPC with dynamic URL path > > > >I am trying to answer my own question. This variation seems to be working: > >html: ><body onload="init('<%= url %>');rpc.get()"> > >myscript.js: > >function init(url){ > rpc=new JsonRPC(url,['get'],[]);} > rpc.get.on_result=function(r){ alert(r); } > rpc.get.on_error=function(e){ alert(e); } >} > >To me, javascript is a new world yet to be explored. > >Regards, >CN > > > > >On Tue, Jul 22, 2014, at 11:24 AM, Lee Elenbaas wrote: >You can still place static files at other urls (even other domain) and have the html refer to them and use them. >>If you absolutely need the js url to change you can serve static files from cppcms app >>בתאריך 21 ביול 2014 17:39, "CN" <cn...@fa...> כתב: >>Please pardon me for asking client question. I have no idea what else >>>place I can ask for help. >>> >>>I prefer to place myscript.js as an external file than to in-line it in >>>HTML page. >>> >>>The URL passed to JsonRPC is determined in run time. As a result, >>>myscript.js can not be coded as below because "/run/time/url" is not >>>static. It is volatile: >>> >>>var rpc=new JsonRPC('/run/time/url',['get'],[]); >>>rpc.get.on_result=function(r){ alert(r); } >>>rpc.get.on_error=function(e){ alert(e); } >>> >>>I also tried this variation: >>> >>>html: >>><body onload="init('<%= url %>');rpc.get()"> >>> >>>myscript.js: >>> >>>function init(url){ rpc=new JsonRPC(url,['get'],[]); } >>>rpc.get.on_result=function(r){ alert(r); } //variable "rpc" is unknown >>>rpc.get.on_error=function(e){ alert(e); } //variable "rpc" is unknown >>> >>>However, my browser complains that variable "rpc" is unknown. >>> >>>Would someone please help me out? >>> >>>Regards, >>>CN > >-- http://www.fastmail.fm - The way an email service should be > >------------------------------------------------------------------------------ >Want fast and easy access to all the code in your enterprise? Index and >search up to 200,000 lines of code with a free copy of Black Duck >Code Sight - the same software that powers the world's largest code >search on Ohloh, the Black Duck Open Hub! Try it now. >http://p.sf.net/sfu/bds > >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |