Skip to content
This repository
Newer
Older
100644 60 lines (55 sloc) 1.423 kb
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
1 <html>
2 <head>
3 <title>Testing html-json library</title>
4 </head>
5 <script src="jsolait/jsolait.js"></script>
6 <script>
7
8 var serviceURL = "json_sample.yaws";
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
9 var methods = [ "test1", "errortest" ];
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
10
11 var jsonrpc = imprt("jsonrpc");
12 var service = new jsonrpc.ServiceProxy(serviceURL, methods);
13
14 function test() {
15 try {
16 foo = document.getElementById('foo').value;
17 bar = document.getElementById('bar').value;
78112471 » vinoski
2011-10-31 whitespace cleanup
18 document.getElementById('result').innerHTML =
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
19 "<PRE>" + service.test1(foo, bar) + "</PRE>";
20 } catch(e) {
0be3c7e8 »
2008-02-14 untabified all of yaws
21 alert(e);
78112471 » vinoski
2011-10-31 whitespace cleanup
22 }
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
23 return false;
24 }
25
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
26 function errortest() {
27 try {
78112471 » vinoski
2011-10-31 whitespace cleanup
28 document.getElementById('failure').innerHTML =
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
29 "<PRE>" + service.errortest() + "</PRE>";
30 } catch(e) {
78112471 » vinoski
2011-10-31 whitespace cleanup
31 document.getElementById('failure').innerHTML =
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
32 "<PRE>" + e + "</PRE>";
78112471 » vinoski
2011-10-31 whitespace cleanup
33 }
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
34 return false;
35 }
36
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
37 </script>
38 <body>
39 <form action="" method="post" onSubmit="return test()">
40 <div id="result">
41 </div>
42 <p>
0be3c7e8 »
2008-02-14 untabified all of yaws
43 First Argument: <input id="foo" />
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
44 </p>
45 <p>
0be3c7e8 »
2008-02-14 untabified all of yaws
46 Second Argument: <input id="bar"/>
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
47 </p>
48 <p>
0be3c7e8 »
2008-02-14 untabified all of yaws
49 <input type="submit" value="Do JSON-RPC call"/>
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
50 </p>
51 </form>
af707a93 » TBBle
2009-11-09 Add example for JSON-RPC returning an error object
52 <form action="" method="post" onSubmit="return errortest()">
53 <p>
54 <input type="submit" value="Do JSON-RPC call expected to fail"/>
55 </p>
56 <div id="failure">
57 </div>
58 </form>
47e5a7c9 »
2006-05-30 JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
59 </body>
60 </html>
Something went wrong with that request. Please try again.