-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsomefile.html
75 lines (54 loc) · 1.54 KB
/
somefile.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<!-- Show off some jQuery functionality -->
<head>
<script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
</head>
<body>
<b>Hello, world</b>
<p class="middle_paragraph">
Something else goes here.
</p>
<!-- The above <p> element is then dynamically replaced with 'Yo', below. -->
<script type="text/javascript">
$("p.middle_paragraph").html("Yo!")
</script>
<p>
Set input value: <input type='text' class='textbox5' value='3'/>
<!-- The above input value is set to '6' -->
<script type="text/javascript">
$("input.textbox5").val("6")
</script>
<p>
Respond to change: <input type='text' class='dyntext' value=''/>
<script type="text/javascript">
$('input.dyntext').change(function() {
alert($('input.dyntext').val()); }
)
</script>
<p>
Retrieve from server: Add <input type='text' class='a' value='' size='4' />
and
<input type='text' class='b' value='' size='4' />:
<p class='toupdate' />
<script type="text/javascript">
function update_result(a, b, c) {
text = '<font color="red"><b>' + a + ' plus ' + b + ' equals ' + c + '</font></b>';
$('p.toupdate').html(text);
}
function do_add() {
a = $('input.a').val();
b = $('input.b').val();
$.ajax({
url: '/rpc',
data: JSON.stringify ({method:'add', params:[a, b,], id:"0"} ),
type: "POST",
dataType: "json",
success: function (data) { update_result(a, b, data.result) },
error: function (err) { alert ("Error");}
});
}
$('input.a').change(do_add);
$('input.b').change(do_add);
</script>
</body>
</html>