So I want to pass a value between javascript file and php file when I click a button. But when I click the button, I dont see the echo, does anyone see the problem? Here are 2 snippets of my code:
test.php:
<script type="text/javascript" src="/functions/js/test.js"></script>
<button type="button" class="btn btn-success" onclick=" myAjax();">Test</button>
<?php
if($_POST['action'] == 'go')
{
echo "worked";
}
?>
and test.js
function myAjax() {
$.ajax({
type: "POST",
url: 'test.php',
data:{action:'go'},
success:function() {
}
});
}