I'm starting in ajax and I've had trouble understanding the error you're experiencing in this example. I click 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><inputtype="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>
test.php:
<?php
if($_POST['action'] == 'call_this') {
echo "YES";
}
?>