teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

chousei

2018/12/07 11:10

投稿

yambejp
yambejp

スコア117908

answer CHANGED
@@ -21,24 +21,30 @@
21
21
 
22
22
  # ajax
23
23
  ```javascript
24
+ <script>
25
+ function monthsSelect(obj){
26
+ var objVar = obj.value;
24
- $.ajax({
27
+ $.ajax({
25
-
28
+ "type" : "GET",
29
+ "url" : "baseSalaryMonth",
30
+ "data" : {baseSalaryMonthStr: objVar},
31
+ "dataType" : "json",
26
- }).done(function(data){
32
+ }).done(function(data){
27
- $('#t1').append($('<thead>')).append($('<tbody>'));
33
+ $('#t1').append($('<thead>')).append($('<tbody>'));
28
- $('<tr>')
29
- .append($('<th>').attr('id','userId').text('ユーザID'))
30
- .append($('<th>').attr('id','fullNm').text('ユーザ名'))
31
- .append($('<th>').attr('id','baseSalary').text('基本給'))
32
- .appendTo($('#t1 thead'));
33
- data.forEach(function(x){
34
34
  $('<tr>')
35
+ .append($('<th>').attr('id','userId').text('ユーザID'))
36
+ .append($('<th>').attr('id','fullNm').text('ユーザ名'))
37
+ .append($('<th>').attr('id','baseSalary').text('基本給'))
38
+ .appendTo($('#t1 thead'));
39
+ data.forEach(function(x){
40
+ $('<tr>')
35
- .append($('<td>').text(x.userId))
41
+ .append($('<td>').text(x.userId))
36
- .append($('<td>').text(x.fullNm))
42
+ .append($('<td>').text(x.fullNm))
37
- .append($('<td>').text(x.baseSalary))
43
+ .append($('<td>').text(x.baseSalary))
38
- .appendTo($('#t1 tbody'));
44
+ .appendTo($('#t1 tbody'));
45
+ });
39
46
  });
40
- });
47
+ };
41
48
  </script>
42
49
  <table id="t1"></table>
43
-
44
50
  ```

1

追記

2018/12/07 11:10

投稿

yambejp
yambejp

スコア117908

answer CHANGED
@@ -17,4 +17,28 @@
17
17
  });
18
18
  }
19
19
  ```
20
- で、受け取ったdataを提示して下さい。まずはそこから
20
+ で、受け取ったdataを提示して下さい。まずはそこから
21
+
22
+ # ajax
23
+ ```javascript
24
+ $.ajax({
25
+
26
+ }).done(function(data){
27
+ $('#t1').append($('<thead>')).append($('<tbody>'));
28
+ $('<tr>')
29
+ .append($('<th>').attr('id','userId').text('ユーザID'))
30
+ .append($('<th>').attr('id','fullNm').text('ユーザ名'))
31
+ .append($('<th>').attr('id','baseSalary').text('基本給'))
32
+ .appendTo($('#t1 thead'));
33
+ data.forEach(function(x){
34
+ $('<tr>')
35
+ .append($('<td>').text(x.userId))
36
+ .append($('<td>').text(x.fullNm))
37
+ .append($('<td>').text(x.baseSalary))
38
+ .appendTo($('#t1 tbody'));
39
+ });
40
+ });
41
+ </script>
42
+ <table id="t1"></table>
43
+
44
+ ```