I wanted to POST variable from JS file to PHP using AJAX. I have both these files in same folder but when I run php code, I don´t see: Warning: Undefined array key "profile_viewer_uid" in C:\xampp\htdocs\zkoska\ppp.php on line 2
Why would be profile_viewer_uid undefined if I have it in JS and code also contains connection: url: "PPP.php",
What is wrong here?
Thank you
javas.js
<script>
var profile_viewer_uid = 1;
$.ajax({
url: "PPP.php",
method: "POST",
data: { "profile_viewer_uid": profile_viewer_uid }
})
</script>
ppp.php
<?php
$profile_viewer_uid = $_POST['profile_viewer_uid'];
echo($profile_viewer_uid);
// prints 1
?>