I sent data to the server using Jquery AJAX but can't access them as $_POST
variable. What am i doing wrong?
The PHP return returns error that the $_POST['name'] is undefined
!
JS CODE
$(document).ready(function() {
function load_friend_request() {
$.ajax({
url: "/friend_requests_main_loader.php",
type: 'POST',
data: { name: 'Kay'},
success: function(html) {
//$("#friend_request:last-child").empty();
$("#friend_request").append(html);
}
})
}
setInterval(function() {
load_friend_request();
}, 2000);
});
</script>```
PHP CODE
`
<?php
echo $_POST['name'];
?>`