-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
53 lines (42 loc) · 1.18 KB
/
test.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
<html>
<body>
<ul>
</ul>
<script src="jquery-3.4.1.js"></script>
<script src="underscore.js"></script>
<input id="coursename" />
<button id="btn">显示学分</button>
<div id="divcredit"></div>
<script>
$(function(){
$.ajax({method:"POST"
,url:"http://localhost:8585/data.json"
,crossDomain: true
,xhrFields: {
withCredentials: true
}
,success:function(data){
// $.post("http://localhost:8585/data.json", function(data){
_.each(data, function(item){
$("ul").append("<li>"+item.name+"(学分:"+item.credit+")"+"</li>");
});
}
});
$("#btn").click(function(){
$.ajax({method:"POST"
,contentType:"application/json"
,crossDomain: true
,xhrFields: {
withCredentials: true
}
,url:"http://localhost:8585/creditByName"
,data:JSON.stringify({name:$("#coursename").val()})
,success:function(data){
$("#divcredit").text(data);
}
});
})
});
</script>
</body>
</html>