-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpage.js
More file actions
59 lines (52 loc) · 1.83 KB
/
page.js
File metadata and controls
59 lines (52 loc) · 1.83 KB
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
var events = {
init: function(){$('#trackNumber').keypress(function (e) {
if (e.which == 13) {
e.preventDefault();
$('#search').click();
return false;
}
});
$("#search").click(function(e) {
//for test, we can use type = shunfeng and postid = 608582127345
// disable search button
$("#search").prop("disabled", true);
$("#container").show();
$("table").hide();
$("#container").html("正在查询的快递:" + $("#trackNumber").val() + " ...");
e.preventDefault();
$.get({
async: true,
url: "http://www.kuaidi100.com/query",
data: {
type: $("#expressType").val(),
postid: $("#trackNumber").val()
},
success: function(data) {
// DO SOMETHING
// enable search button
$("#search").prop("disabled", false);
var resp = JSON.parse(data);
if (resp["status"] === "200") {
$("tbody").empty();
for (var d of resp["data"]) {
$("#container").hide();
$("table").show();
// append line of to table
$("tbody").append("<tr><td>"+ d["time"]+ "</td><td>" + d["context"]+"</td></tr>");
}
} else {
for (var key in resp) {
if (resp.hasOwnProperty(key)) {
$("#container").html("<div class='alert alert-danger' id='error'></div>");
$("#error").append("<p>参数错误</p>");
}
}
}
}
});
});
}
}
$(document).ready(function() {
events.init();
});