I need help, if an image is clicked, then in the database will insert 1 value.
Example, if I click code
then in the database will insert 1
in number_of_click
. Then if I click code
again, it will insert 2
etc.
But I am using Laravel 5.2, so I am so confused
<a onclick="addAds()" id="add" target="_blank" href="{{$ads1->link}}"><img src="{{URL::asset('Gambar')}}/{{$ads1->image}}" alt=""/></a>
click = 0;
function addClick(){
click++;
$.ajax({
url: "Your-URL",
type: "post",
data: {'click': click},
success: function (response){
if(response){
alert("Click has been inserted.");
}
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="javascript:void(0);" onclick="addClick();">Click</a>
In Your Your-Url Page handle this request and insert into the database as per your requirement.
For more information: http://www.tutorialspoint.com/php/php_and_ajax.htm
</div>