Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (55 sloc) 1.423 kb
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
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";
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
9 var methods = [ "test1", "errortest" ];
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
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;
7811247 @vinoski whitespace cleanup
vinoski authored
18 document.getElementById('result').innerHTML =
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
19 "<PRE>" + service.test1(foo, bar) + "</PRE>";
20 } catch(e) {
0be3c7e @klacke untabified all of yaws
authored
21 alert(e);
7811247 @vinoski whitespace cleanup
vinoski authored
22 }
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
23 return false;
24 }
25
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
26 function errortest() {
27 try {
7811247 @vinoski whitespace cleanup
vinoski authored
28 document.getElementById('failure').innerHTML =
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
29 "<PRE>" + service.errortest() + "</PRE>";
30 } catch(e) {
7811247 @vinoski whitespace cleanup
vinoski authored
31 document.getElementById('failure').innerHTML =
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
32 "<PRE>" + e + "</PRE>";
7811247 @vinoski whitespace cleanup
vinoski authored
33 }
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
34 return false;
35 }
36
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
37 </script>
38 <body>
39 <form action="" method="post" onSubmit="return test()">
40 <div id="result">
41 </div>
42 <p>
0be3c7e @klacke untabified all of yaws
authored
43 First Argument: <input id="foo" />
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
44 </p>
45 <p>
0be3c7e @klacke untabified all of yaws
authored
46 Second Argument: <input id="bar"/>
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
47 </p>
48 <p>
0be3c7e @klacke untabified all of yaws
authored
49 <input type="submit" value="Do JSON-RPC call"/>
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
50 </p>
51 </form>
af707a9 Add example for JSON-RPC returning an error object
Paul Hampson authored
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>
47e5a7c @klacke JSON ajax code from Gaspar Chilingarov, I added docs describing an ex…
authored
59 </body>
60 </html>
Something went wrong with that request. Please try again.