Reputation: 471
I am using $.ajax jquery method, to post num to php, but im not sure how to pick it up on the php side, this is what i have, gives an undefined index error on num so its not finding it.
I would like to know how to pick the variable up in php after posting it there via the $.ajax method.
<?php
$lol = $_POST['num'];
echo " $lol";
?>
this is the JS:
<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 JS is carried out on click of a button
Upvotes: 1
Views: 155