1
Well, I have a PHP variable a page index.php. And when I click, I load another part of the page inside a div with javascript. When loading the page, the index variable is not recognized inside the div page (which is also . php).
<?php
$variavel = 1234;
?>
<script>
function carregar(pagina){
$("#conteudo").load(pagina);
}
</script>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" onclick="carregar('includes/graficos/pesoaluno.php')" href="#">Registro de peso</a>
</li>
</ul>
<div id="conteudo"></div>
You can switch to a variable
Javascript
thus:var x = '<?php echo $variavel;?>';
– Ricardo Pontual