Error in $ .post method

0

The index.html page contains:

<!DOCTYPE html>
<html>
<head>
    <title>teste</title>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="script.js"></script>
</head>
<body>
<a href="teste.php"><img id="adicionar" src="aceitar.jpg" alt="aceitar" style="height: 75px"></a>
</body>
</html>

The script.js contains:

$(document).ready(function(){
    $("#adicionar").click(function(){
        alert ("A imagem foi clicada");
        $.post( "teste.php", {name: "John"} );
    });
});

And finally test.php:

<?php
if(isset($_POST['name'])){
    $name=$_POST['name'];
    echo $name;
} else {
    echo "O método POST falhou!";
}
?>

What is the error in this basic example of the $ .post method?

    
asked by anonymous 20.06.2017 / 20:03

0 answers