回答編集履歴

1

chousei

2019/10/10 09:23

投稿

yambejp
yambejp

スコア114779

test CHANGED
@@ -1 +1,63 @@
1
1
  JSONと書かれているデータがJSON型ではありません
2
+
3
+
4
+
5
+ # sample
6
+
7
+
8
+
9
+ まずはこうしてみてください
10
+
11
+ ```javascript
12
+
13
+ <script>
14
+
15
+ $(function(){
16
+
17
+ $('#ajax').on('click',function(){
18
+
19
+ $.ajax({
20
+
21
+ url:'test.json',
22
+
23
+ type:'GET',
24
+
25
+ dataType: 'json',
26
+
27
+ data:{
28
+
29
+ 'Year':$('#Year').val(),
30
+
31
+ 'Name':$('#Name').val()
32
+
33
+ },
34
+
35
+ }).done( (searchResult) => {
36
+
37
+ console.log("成功");
38
+
39
+ console.log(searchResult);
40
+
41
+ $('.result').html(JSON.stringify(searchResult));
42
+
43
+ });
44
+
45
+ });
46
+
47
+ });
48
+
49
+ </script>
50
+
51
+ <input type="button" value="ajax" id="ajax">
52
+
53
+ <div class="result"></div>
54
+
55
+ ```
56
+
57
+ - test.json
58
+
59
+ ```json
60
+
61
+ [{"testingDateFrom":"1", "testingDateTo":"2","competitionName":"3", "kitSendPrefecture":"4","associationName":"5", "subAssociationName":"6"}]
62
+
63
+ ```