我有一个像这样的 Ajax 脚本,其中包含一个要处理的文件 getvar.php:
<script type="text/javascript">
$(document).ready(function() {
$(".jenisdata").change(function() {
var jenisdata =$(this).val();
var dataString = 'jenisdata='+jenisdata;
$.ajax({
type: "POST",
url: "includes/analisis/getvar.php",
data: dataString,
cache: false,
success: function(html) {
$(".variabel").html(html);
}
});
});
});
</script>
而获取从 Ajax 传递的变量的 getvar.php 是这样的:
<?php
include ('../../../config/config.php');
$id_user=$_SESSION['id_user'];
if($_POST['jenisdata']) {
$id= $_POST['jenisdata'];
$query = "SELECT var.id_var, var.nama_var
FROM var, hak_akses
WHERE var.id_var = hak_akses.id_var
AND id_user ='$id_user' AND id_data ='$id'";
$results = mysql_query( $query);
$total = mysql_num_rows($results);
if ($total >0) {
while ($rows = mysql_fetch_assoc($results)) {
echo '<option value="'.$rows['id_var'].'">'.$rows['nama_var'].'</option>';
}
} else {
echo '<option value="" selected="selected">Data variabel belum diisi dijenisdata Ini</option>';
}
}
?>
$_SESSION['id_user']
此处无法读取该变量。有什么问题,如何在 Ajax 包含的文件中获取会话?