Basically I need to use a JavaScript variable in a php to later register in the database. I have a <a href="carrinho.php"><button id="btnTestar">TESTE</button></a>
button that leads to the cart.php page.
In the cart.php page I want to receive the variable.
$teste = $_POST['teste'];
ajax code
$(document).ready(function () {
$("#btnTestar").click(function(){
var teste = "testando";
$.ajax({
type: "POST",
url: "carrinho.php",
data:{'teste':teste},
success: success,
dataType: dataType
});
});
});
I do not know what's wrong because I've never used ajax before so I'm in doubt.
The error that appears on the php page is essse Notice: Undefined index: teste