can't load php file with jquery and access variable outside the file -
if load php file (home.php) via jquery, can't seem able access $var in home.php file. loads succesfuly "undefined" error:
( ! ) notice: undefined variable: var in /media/sf_sandbox/linksup/view/home.php
i have done in exact same order. declare variable:
index.php
<?php $var = "bar"; ?>
i load file home.php .load():
index.php
<div id="contentcontainer"> <script> $( "#contentcontainer" ).load( "view/home.php" ); </script> </div>
i try value of $var in home.php:
home.php
<div class="row"> <div class="col-md-12"> <h2>home</h2> <?php echo $var?> </div> </div>
why using jquery purpose. php include_once()
easily.
in home.php
below:-
<?php include_once('index.php');?> <div class="row"> <div class="col-md-12"> <h2>home</h2> <?php echo $var?> </div> </div>
Comments
Post a Comment