What I have:
I created several buttons through PHP and to distinguish them I used the $botoes_criados
variable.
So I have the value of the $botoes_criados
variable in PHP that is passed to a button as follows:
echo("<li><a href='#' onclick='pagination($botoes_criados)'>$botoes_criados</a></li>");
Then I made a javascript to receive through the function pagination()
receives the variable $botoes_criados
through the parameter.
What I intend to do: I want to pass the value of this variable back to PHP so I know which button was clicked.
What I tried to do:
<script>
function pagination(botao)
{
alert(window.location.href );
var xhttp = new XMLHttpRequest();
xhttp.open("GET", window.location.href, true);
xhttp.send("b=".botao);
}
</script>
In PHP I have the following code to try to get the value of the variable
Echo($_GET['b']);
In short: All I want is to make an XMLHTTPrequest for the page itself so I can collect the information from that variable. If you do not understand my question, I will edit it.