-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
46 lines (41 loc) · 1.22 KB
/
example.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
<!--
(c) Copyright 2019, Pongsakorn Ritrugsa <[email protected]>
This project is licensed under the terms of the MIT license.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ThaiIDCard-WebAPI | Example</title>
</head>
<body>
<form>
IDCard <input id="idcard" type="text" value=""><br>
<button type="button" id="generate_button">Generate</button>
<button type="button" id="verify_button">Verify</button>
<button type="reset">Clear</button>
</form>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script>
var api_url = "http://localhost:8000";
$("#generate_button").click(function() {
$.getJSON(`${api_url}/?command=generate`, function(json) {
$("#idcard").val(json.idcard);
});
});
$("#verify_button").click(function() {
var idcard = $("#idcard").val();
$.getJSON(`${api_url}/?command=verify&idcard=${idcard}`)
.done(function(json) {
alert(`idcard=${json.idcard}, valid=${json.valid}`);
})
.fail(function(jqxhr, textStatus, errorMessage) {
alert(jqxhr.responseJSON.message);
});
});
</script>
</body>
</html>