0
I am starting in ajax and I have had difficulty understanding the error you are giving in this example. I click on the button and no action is taken.
HTML:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<title></title>
</head>
<body>
<input type="button" value="Testar" onclick="myAjax();"></input>
</body>
</html>
<script>
function myAjax() {
$(document).ready(function()
{
$.ajax({
type: "POST",
url: 'teste.php',
data:{action:'call_this'},
success:function(html) {
alert(html);
}
});
return false;
}
</script>
php test.:
<?php
if($_POST['action'] == 'call_this') {
echo "YES";
}
?>
What error occurs? Any message appears?
– Guilherme Nascimento
He says nothing, just gives no answer to the code @Guilhermenascimento
– Wilton Neto