-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
105 lines (103 loc) · 3.14 KB
/
demo.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试页</title>
</head>
<body>
<h1>商品添加</h1>
<form id="add_form">
<table>
<tr>
<th>商品名称:</th>
<td>
<input type="text" id="itemName">
</td>
<th>商品价钱:</th>
<td>
<input type="text" id="price">
</td>
</tr>
<tr>
<th>是否包邮:</th>
<td>
<input type="radio" name="free_deliverly" value="1">是
<input type="radio" name="free_deliverly" value="0">否
</td>
<th>商品状态:</th>
<td>
<input type="radio" name="status" value="1">上架
<input type="radio" name="status" value="0">下架
</td>
</tr>
<tr>
<th>商品库存:</th>
<td>
<input type="text" id="stock">
</td>
</tr>
<tr>
<th>商品图片1:</th>
<td>
<input type="text" id="img1" value="http://omy6hbb54.bkt.clouddn.com/hadeng.jpg">
</td>
<th>商品图片1描述:</th>
<td>
<input type="text" id="img1_text">
</td>
</tr>
<tr>
<th>商品图片2:</th>
<td>
<input type="text" id="img2" value="http://omy6hbb54.bkt.clouddn.com/%E5%A4%B4%E5%83%8F.PNG">
</td>
<th>商品图片2描述:</th>
<td>
<input type="text" id="img2_text">
</td>
</tr>
<tr>
<td>
<input type="button" id="submit_btn" value="添加">
</td>
</tr>
</table>
</form>
<script type="text/javascript" src="./js/lib/zepto.min.js"></script>
<script type="text/javascript">
$(function() {
var $btn = $("#submit_btn");
$btn.on("click", function() {
var itemName = $("#itemName").val();
var price = $("#price").val();
var stock = $("#stock").val();
var status = $("input[name='status']:checked").val()
var freeDeliverly = $("input[name='free_deliverly']:checked").val();
var bigImgs = [];
bigImgs.push($("#img1").val());
bigImgs.push($("#img2").val());
var titles = [];
titles.push($("#img1_text").val());
titles.push($("#img2_text").val());
$.ajax({
url: "http://localhost:8083/item/add",
type: 'POST',
data:{
titles:titles,
stock:stock,
bigImgs:bigImgs,
status:status,
freeDeliverly:freeDeliverly,
price:price,
itemName:itemName
},
success:function(res){
res = typeof res === 'string' ? JSON.parse(res) : res;
console.log(res);
}
})
});
})
</script>
</body>
</html>