call a php function in jquery code example
Example 1: call php function in js
<script>
var phpadd= <?php echo add(1,2);?> //call the php add function
var phpmult= <?php echo mult(1,2);?> //call the php mult function
var phpdivide= <?php echo divide(1,2);?> //call the php divide function
</script>
Example 2: jquery code to trigger php function
$.ajax({ url: 'phpscriptname.php',
data: {function2call: 'getEmployeesList', otherkey:otherdata},
type: 'post',
success: function(output) {
alert(output);
}
});