回答編集履歴

2

chousei

2018/12/07 11:10

投稿

yambejp
yambejp

スコア114583

test CHANGED
@@ -44,44 +44,56 @@
44
44
 
45
45
  ```javascript
46
46
 
47
- $.ajax({
47
+ <script>
48
48
 
49
+ function monthsSelect(obj){
49
50
 
51
+ var objVar = obj.value;
50
52
 
51
- }).done(function(data){
53
+ $.ajax({
52
54
 
53
- $('#t1').append($('<thead>')).append($('<tbody>'));
55
+ "type" : "GET",
54
56
 
55
- $('<tr>')
57
+ "url" : "baseSalaryMonth",
56
58
 
57
- .append($('<th>').attr('id','userId').text('ユーザID'))
59
+ "data" : {baseSalaryMonthStr: objVar},
58
60
 
59
- .append($('<th>').attr('id','fullNm').text('ユーザ名'))
61
+ "dataType" : "json",
60
62
 
61
- .append($('<th>').attr('id','baseSalary').text('基本給'))
63
+ }).done(function(data){
62
64
 
63
- .appendTo($('#t1 thead'));
65
+ $('#t1').append($('<thead>')).append($('<tbody>'));
64
-
65
- data.forEach(function(x){
66
66
 
67
67
  $('<tr>')
68
68
 
69
- .append($('<td>').text(x.userId))
69
+ .append($('<th>').attr('id','userId').text('ユーザID'))
70
70
 
71
- .append($('<td>').text(x.fullNm))
71
+ .append($('<th>').attr('id','fullNm').text('ユーザ名'))
72
72
 
73
- .append($('<td>').text(x.baseSalary))
73
+ .append($('<th>').attr('id','baseSalary').text('基本給'))
74
74
 
75
+ .appendTo($('#t1 thead'));
76
+
77
+ data.forEach(function(x){
78
+
79
+ $('<tr>')
80
+
81
+ .append($('<td>').text(x.userId))
82
+
83
+ .append($('<td>').text(x.fullNm))
84
+
85
+ .append($('<td>').text(x.baseSalary))
86
+
75
- .appendTo($('#t1 tbody'));
87
+ .appendTo($('#t1 tbody'));
88
+
89
+ });
76
90
 
77
91
  });
78
92
 
79
- });
93
+ };
80
94
 
81
95
  </script>
82
96
 
83
97
  <table id="t1"></table>
84
98
 
85
-
86
-
87
99
  ```

1

追記

2018/12/07 11:10

投稿

yambejp
yambejp

スコア114583

test CHANGED
@@ -37,3 +37,51 @@
37
37
  ```
38
38
 
39
39
  で、受け取ったdataを提示して下さい。まずはそこから
40
+
41
+
42
+
43
+ # ajax
44
+
45
+ ```javascript
46
+
47
+ $.ajax({
48
+
49
+
50
+
51
+ }).done(function(data){
52
+
53
+ $('#t1').append($('<thead>')).append($('<tbody>'));
54
+
55
+ $('<tr>')
56
+
57
+ .append($('<th>').attr('id','userId').text('ユーザID'))
58
+
59
+ .append($('<th>').attr('id','fullNm').text('ユーザ名'))
60
+
61
+ .append($('<th>').attr('id','baseSalary').text('基本給'))
62
+
63
+ .appendTo($('#t1 thead'));
64
+
65
+ data.forEach(function(x){
66
+
67
+ $('<tr>')
68
+
69
+ .append($('<td>').text(x.userId))
70
+
71
+ .append($('<td>').text(x.fullNm))
72
+
73
+ .append($('<td>').text(x.baseSalary))
74
+
75
+ .appendTo($('#t1 tbody'));
76
+
77
+ });
78
+
79
+ });
80
+
81
+ </script>
82
+
83
+ <table id="t1"></table>
84
+
85
+
86
+
87
+ ```