Skip to content

Commit 70d7a9b

Browse files
committed
ajax when clicked the vote button
1 parent 7bbcac3 commit 70d7a9b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

resources/js/app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ Vue.component('example-component', require('./components/ExampleComponent.vue').
3030
const app = new Vue({
3131
el: '#app',
3232
});
33+
34+
35+
$('.btn-vote').each(function(i, el){
36+
$(el).click(function(){
37+
$.ajax({
38+
type: 'GET',
39+
url: '/track.php?vote_method='+ vote_method+ '&' + 'photoID=' + photo_id
40+
});
41+
});
42+
43+
});

resources/views/welcome.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@
8787
<p class="card-text">{{ $photo->Description }}</p>
8888
<div class="d-flex justify-content-between align-items-center">
8989
<div class="btn-group">
90-
<button type="button" class="btn btn-sm btn-outline-secondary">
91-
<a href="/track.php?vote_method=up&photoID={{$photo->picID}}"><span class="oi oi-arrow-thick-top"></span></a>
90+
<button type="button" class="btn btn-sm btn-outline-secondary btn-vote" data-photo-id="{{$photo->picID}}" data-vote-direction="up"><
91+
span class="oi oi-arrow-thick-top"></span>
9292
</button>
93-
<button type="button" class="btn btn-sm btn-outline-secondary">
94-
<a href="/track.php?vote_method=down&photoID={{$photo->picID}}"><span class="oi oi-arrow-thick-bottom"></span></a>
93+
<button type="button" class="btn btn-sm btn-outline-secondary btn-vote" data-photo-id="{{$photo->picID}}" data-vote-direction="down">
94+
<span class="oi oi-arrow-thick-bottom"></span>
9595
</button>
9696
</div>
9797
<small class="text-muted">{{ $photo->Votes}} votes</small>

0 commit comments

Comments
 (0)