forked from erlyaws/yaws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_sample.html
60 lines (55 loc) · 1.39 KB
/
json_sample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<html>
<head>
<title>Testing html-json library</title>
</head>
<script src="jsolait/jsolait.js"></script>
<script>
var serviceURL = "json_sample.yaws";
var methods = [ "test1", "errortest" ];
var jsonrpc = imprt("jsonrpc");
var service = new jsonrpc.ServiceProxy(serviceURL, methods);
function test() {
try {
foo = document.getElementById('foo').value;
bar = document.getElementById('bar').value;
document.getElementById('result').innerHTML =
"<PRE>" + service.test1(foo, bar) + "</PRE>";
} catch(e) {
alert(e);
}
return false;
}
function errortest() {
try {
document.getElementById('failure').innerHTML =
"<PRE>" + service.errortest() + "</PRE>";
} catch(e) {
document.getElementById('failure').innerHTML =
"<PRE>" + e + "</PRE>";
}
return false;
}
</script>
<body>
<form action="" method="post" onSubmit="return test()">
<div id="result">
</div>
<p>
First Argument: <input id="foo" />
</p>
<p>
Second Argument: <input id="bar"/>
</p>
<p>
<input type="submit" value="Do JSON-RPC call"/>
</p>
</form>
<form action="" method="post" onSubmit="return errortest()">
<p>
<input type="submit" value="Do JSON-RPC call expected to fail"/>
</p>
<div id="failure">
</div>
</form>
</body>
</html>