-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
45 lines (45 loc) · 1.01 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Simple Calculation</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<form id="form1">
<input type="text" name="num1" placeholder="Number 1"><input type="text" name="num2" placeholder="Number 2">
<select name="action">
<option value="add">+</option>
<option value="sub">-</option>
<option value="mul">X</option>
<option value="mod">%</option>
<option value="div">/</option>
</select>
<input type="submit" value="Show Result">
</form>
<hr>
<div id="result"></div>
<script type="text/javascript">
$('#form1').submit(function() {
var dataString = $('#form1').serialize();
$.ajax({
url: 'server.php',
type: 'POST',
data: dataString,
success : function (data) {
$('#result').html(data);
}
})
.done(function() {
console.log("success");
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
return false;
});
</script>
</body>
</html>