I am having trouble with this jQuery function that is supposed to post the value of a variable to a PHP page and display it in the correct status class. I have included the necessary jQuery file, but for some reason, nothing is happening.
Any assistance would be greatly appreciated. Thank you!
<script>
var num = 1;
function ajax_post(){
$.ajax('javas.php', {
success: function(response) {
$(".status").html(response);
},
data: "num=" + (++num)
});
}
function ajax_posta(){
$.ajax('javas.php', {
success: function(response) {
$(".status").html(response);
},
data: "num=" + (--num)
});
}
$(document).ready(function() {
$('.eventer > .button').click(function () {
ajax_post();
});
alert("lol");
});
</script>
This is my current setup, including the PHP code related to classes:
<div id='eventcontainer'>
<?php
// Retrieve posts from DB
$event1 = mysql_query("SELECT post,date,memid FROM postaction WHERE memid = '$id' ORDER BY date DESC LIMIT 5;");
while ($row1 = mysql_fetch_array($event1))
{
$event = $row1['post'];
$timeposted = $
row1['date'];
$eventmemdata = mysql_query("SELECT id,firstname FROM users WHERE id = '$id' LIMIT 1");
while($rowaa = mysql_fetch_array($eventmemdata))
{
$name = $rowaa['firstname'];
$eventlist = "$event <br> $name";
}
echo "<div class='eventer'> $timeposted <br>$eventlist <input name='myBtn' type='submit' value='increment' onClick='javascript:ajax_post();'>
<input name='lol' type='submit' value='dec' onClick='javascript:ajax_posta();'></div>
<div class='status'></div>";
echo "<br>";
}
?>