【发布时间】:2015-12-05 07:12:10
【问题描述】:
我搜索了一种解决方案,将从 index.php 页面获得的 get 变量传递给 include.php 文件[由 javascript 加载]。 php require 函数给出了一个很好的解决方案Pass and print a $_GET variable through an included file by php require function
然而,就我而言,我有
for index.php => url[ index.php?var=item]
<?php
if(isset($_GET['var'])) {
$var=$_GET['var'];
}
?>
<script>
$(document).ready(function(){
$("#ok").load("included.php");
});
</script>
<div id='ok'>
</div>
in included.php [which will be loaded in index.php by javascript load function]
<?php
echo $var;
?>
错误是included.php 文件中未定义的变量。如何结合php 和javascript 回显这个变量?
【问题讨论】:
标签: javascript php load