Im trying to send a js variable value to php using ajax. So when the page loads, it will do the job, at the same url. Im trying this but nothing seams to work:
*<script>
$(document).ready(function() {
var postID = 5;
$.ajax({
type: "POST",
url: '',
data: "userID=" + postID,
success: function(data)
{
alert("success!");
}
});
});
</script>
<?php
$postID = (isset($_POST['postID'])) ? $_POST['postID'] : 0;
if($postID==0) {
echo 'User ID not found';
}
?>*