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

質問編集履歴

1

書式の改善

2017/11/20 11:51

投稿

shiro_momo
shiro_momo

スコア8

title CHANGED
File without changes
body CHANGED
@@ -64,4 +64,41 @@
64
64
  <li id="button_2"><img src="/img/jp/JP2.png" width="345px" alt="" id="title_2"></li>
65
65
  <li id="button_3"><img src="/img/jp/JP3.png" width="345px" alt="" id="title_3"></li>
66
66
  </ul>
67
+ ```
68
+
69
+ ご回答ありがとうございます。
70
+ masaya_ohashi様とyambejp様のものをヒントにし、組み直してみました(データの型も修正しています。)。
71
+ switchで切り替える手法も取り入れてみたいと思います。
72
+ こちら、おかしいところありますでしょうか。
73
+
74
+ ```ここに言語を入力
75
+ <script>
76
+ $(".ajax_send")
77
+ .click(function() {
78
+ var _this = this;
79
+ var pramObj = new Object({
80
+ "btn":$(_this).data('post-btn'),
81
+ "pc":$(_this).data('post-pc'),
82
+ "lang":$(_this).data('post-lang')
83
+ });
84
+ parseInt($(this).data('post-pc')) + "&lang=" + $(this).data('post-lang');
85
+ $.ajax({
86
+ url:hostUrl,
87
+ type:'POST',
88
+ dataType:'text',
89
+ data:pramObj,
90
+ }).done(function(data) {
91
+
92
+ }).fail(function(XMLHttpRequest, textStatus, errorThrown) {
93
+
94
+ }).always(function( jqXHR, textStatus ) {
95
+ });
96
+ });
97
+
98
+ });
99
+ </script>
100
+
101
+ <li id="button_1" class="ajax_send" data-post-btn="A" data-post-pc="1" data-post-lang="jp"><img src="/img/jp/JP1.png" width="345px" alt="" id="title_1"></li>
102
+ <li id="button_2" class="ajax_send" data-post-btn="B" data-post-pc="1" data-post-lang="jp"><img src="/img/jp/JP2.png" width="345px" alt="" id="title_2"></li>
103
+ <li id="button_3" class="ajax_send" data-post-btn="C" data-post-pc="1" data-post-lang="jp"><img src="/img/jp/JP3.png" width="345px" alt="" id="title_3"></li>
67
104
  ```