This jQuery function is meant to post the value of num to a PHP page and then echo it in the correct status class, any ideas why nothing is happening, I have downloaded jQuery and called the file further up (not displayed here)
Any help is appreciated thanks!
<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 what i have, this is my php code concerning the classes.
<div id = 'eventcontainer' >
<?php
//Getting 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>";
}
?>
Instead of
$.postchange it to $.ajaxYou could re-arrange the parameters to get it to work with $.post, but it looks like the code you have is meant to be run with $.ajax.
Also, inside of here
Are you sure you didn’t mean: