[Cppcms-users] Instantiate JsonRPC with dynamic URL path
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2014-07-21 14:39:25
|
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 - A fast, anti-spam email service.
|