How to pass jquery variable to database and output value??
Hello -
I am trying to set up a non-cookied counter which will stay saved at a current value for all visitors coming onto the site (and can increase the counter).
It is here :
http://www.kennyrosenberg.com/?page_id=19
The likes are at 0 when you first go to the page but I always want them to be saved and increasing whenever someone clicks like.
The value of the variable is "i"
$(function() {
// generate markup
$("#rating").text("Likes : " + 0);
var i = 0;
// add markup to container and apply click handlers to anchors
$("a#add").click(function(e){
// stop normal link click
e.preventDefault();
i++;
// send request
$("#rating").text("Likes : " + i);
});
// generate markup
$("#norating").text("Dislikes : " + 0);
var n = 0;
// add markup to container and apply click handlers to anchors
$("a#remove").click(function(e){
// stop normal link click
e.preventDefault();
n++;
// send request
$("#norating").text("Dislikes : " + n);
});
});
<span id="rating" style="font-size:20px;">
</span>
<span id="norating" style="font-size:20px;">
</span>
<a href="#" id="add">Like This</a><br />
<a href="#" id="remove">Dislike This</a>