質問編集履歴
2
ソースコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,3 +93,61 @@
|
|
93
93
|
});
|
94
94
|
|
95
95
|
```
|
96
|
+
|
97
|
+
```JavaScript
|
98
|
+
|
99
|
+
//修正
|
100
|
+
|
101
|
+
$(function () {
|
102
|
+
|
103
|
+
$("[id^=likes]").on('click', function(e){
|
104
|
+
|
105
|
+
e.preventDefault();
|
106
|
+
|
107
|
+
var formData = new FormData($('#example_form').get(0));
|
108
|
+
|
109
|
+
var id = this.id;
|
110
|
+
|
111
|
+
id = id.replace("likes","");
|
112
|
+
|
113
|
+
$.ajax({
|
114
|
+
|
115
|
+
url: 'likes_count.php',
|
116
|
+
|
117
|
+
data:{
|
118
|
+
|
119
|
+
"id": id,
|
120
|
+
|
121
|
+
formData
|
122
|
+
|
123
|
+
},
|
124
|
+
|
125
|
+
type: 'POST',
|
126
|
+
|
127
|
+
cache: false,
|
128
|
+
|
129
|
+
dataType: 'json',
|
130
|
+
|
131
|
+
contentType: false,
|
132
|
+
|
133
|
+
processData: false,
|
134
|
+
|
135
|
+
success: function(data){
|
136
|
+
|
137
|
+
alert('成功');
|
138
|
+
|
139
|
+
},
|
140
|
+
|
141
|
+
error: function(){
|
142
|
+
|
143
|
+
alert('error');
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
});
|
148
|
+
|
149
|
+
})
|
150
|
+
|
151
|
+
});
|
152
|
+
|
153
|
+
```
|
1
ソースコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -49,3 +49,47 @@
|
|
49
49
|
・・・
|
50
50
|
|
51
51
|
```
|
52
|
+
|
53
|
+
```JavaScript
|
54
|
+
|
55
|
+
$(function () {
|
56
|
+
|
57
|
+
$("[id^=likes]").click(
|
58
|
+
|
59
|
+
function(){
|
60
|
+
|
61
|
+
var id = this.id;
|
62
|
+
|
63
|
+
$.ajax({
|
64
|
+
|
65
|
+
url: 'likes_count.php',
|
66
|
+
|
67
|
+
data:{"id": id},
|
68
|
+
|
69
|
+
type: 'POST',
|
70
|
+
|
71
|
+
cache: false,
|
72
|
+
|
73
|
+
dataType: 'json',
|
74
|
+
|
75
|
+
success: function(data){
|
76
|
+
|
77
|
+
alert('成功');
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
error: function(){
|
82
|
+
|
83
|
+
alert('error');
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
);
|
92
|
+
|
93
|
+
});
|
94
|
+
|
95
|
+
```
|