Re: [Cppcms-users] Instantiate JsonRPC with dynamic URL path
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2014-07-22 05:50:21
|
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" <[1]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
References
1. mailto:cn...@fa...
--
http://www.fastmail.fm - The way an email service should be
|