JSFiddle - React, Tailwind, and code Playground
HTML
<button type="button" id="hello">Hello</button>
<button type="button" id="bye">Bye</button>
JavaScript
$(document).ready(function() {
$("#hello").click(hello);
$("#bye").click(bye);
});
function hello() {
alert('hello called');
$.ajax({
url: 'func.php',
data: {
action: 'hello'
},
type: 'post',
success: function (output) {
alert(output);
}
});
}
function bye() {
alert('bye called');
$.ajax({
url: 'func.php',
data: {
action: 'bye'
},
type: 'post',
success: function (output) {
alert(output);
}
});
}