I am getting an error for the line of code included in a js file.

$(document).ready(function(){
        //Click "Cancel" button return to Restaurant Manager Page
        $("input[name=btCancel]").click(function(){
            window.location.href = "<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>";
        });
}); 

The uncaught exception points to

window.location.href = "<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>";

Is it because I cannot mix JavaScript with PHP code. Your help is kindly appreciated.

Is it because I cannot mix JavaScript with PHP code.

Correct.

Any suggestion how do I decouple the PHP code and JavaScript code? Just an idea, in my PHP page I do this:

<script language='javascript'> var a="<?php echo APP_WEB_PATH,"/branch_manager.php?id=".$_GET['id'];?>"; </script>

Then in my javascript code:

$(document).ready(function(){
        //Click "Cancel" button return to Restaurant Manager Page
        $("input[name=btCancel]").click(function(){
            window.location.href = a;
        });
}); 

I haven't tested. Just a theory. However it looks insecure.

Technically, it's just a redirect. How insecure can it be?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.