File structure is
functions/functions.php
function name($name){
return $name;
}
HTML file
<?php include("./functions/functions.php") ?>
<script src="./js/custom.js"></script>
<button id="btn">click me</button>
JS/custom.js
$("#btn").click(function(){
var name = <?php echo name("Alex");?>
alert(name);
});
This is not working, can someone please tell me what am I doing wrong? I'm getting : 'Uncaught SyntaxError: Unexpected token < ' in the console.
--
Edit : Error disappears after I made the change
var name = '<?php echo name("Alex");?>';
However, I'm still not gettion the alert.