I have a navigation bar saved as menu.php.Then in my main page I created a button called" Inject".This is supposed to append a php include tag when clicked. Here is my code:
$(document).ready(function(){
$("#inject").click(function(){
$("body").append("<?php include '../menu.php'; ?>");
});
});
<body>
<div class="container">
<div class="jumbotron landing">
<h1 class="text-center"><span class="text-primary">Hex to Rgb converter V1.0 </span></h1>
</div>
<div id="inject" class="btn btn-danger">Inject</div>
<h1>Enter hex code without <kbd>#</kbd> and press <kbd>Enter</kbd></h1>
<kbd class="h3">#</kbd><span class="h4 bg-primary">+</span><input type="text" maxlength="6" id="hex" class="text-warning bg-info h3 img-rounded" pattern="[A-Fa-f]{6}" title="Type a hex code please">
<h1>Rgb</h1>
<p id="rgb" class="h4 text-primary bg-success"></p>
</div>
</body>
The problem That i get on js console(chromium) is"Uncaught SyntaxError: Unexpected identifier" The php include tag will work fine when it is not inserted by javascript. Any ideas?