i have read in many place that i can t pass a variable of js to the php code but i don t understand why, ok i know that it isn t so tidy make that but i didn t know why i could do that, here i have a few trys but i cant achieve anything
<!DOCTYPE html>
<html>
<body>
<button type="button" id="myBtn" onclick="myFunction()">Go</button>
<script>
function myFunction() {
var x = document.getElementById("myBtn");
var str="holi58";
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","test.php?q="+str,true);
xmlhttp.send();
}
</script>
<?php
echo $_POST['q'];
echo $_REQUEST['q'];
echo $_GET['q'];
echo $_REQUEST["q"];
?>
here you can see that the netword detect that arrive the request but i not understand why the page don t show the value