as the question stated. everytime auto refresh 5s, its removing the session and give me the errors Notice: undefined variables in get_total_un_booking and get_total_un_booking
.
before tag ive got php include and classes:
session_start();
require_once '../_include/user.inc.php';
require_once '../_include/booking.inc.php';
$user= new user;
$booking = new booking;
$getUser = $user->getUser($_GET['id_user']);
$getBookslot = $booking->get_bookslot($_GET['b_ref']);
HTML Nav:
<table id="nav">
<tr>
<td><? include 'pages/nav.php'; ?></td>
</tr>
</table>
in Nav.php:
<? if($booking->开发者_运维百科get_total_un_booking() == 0) :
echo '<a href="home.php?confirm"><span></span>Booking</a>';
?>
<? if($booking->get_total_un_booking() == 0) :
echo '<a href="home.php?testimonial"><span></span>Confirm Testmnl</a>';
?>
jQuery:
$(document).ready(function(){
setInterval(function() {
$("#nav").load('pages/nav.php');
}, 5000);
});
If you want access to the session variables in pages/settings.php , you must call session_start()
on that page.
You can always transfer the session variable manually (presuming the JS comes from your PHP document):
$(document).ready(function(){
setInterval(function() {
$("#content").load('pages/setting.php?PHPSESSID=<?=session_id();?>');
}, 5000);
});
Your code uses values from _GET
array, but your .load()
doesn't provide any - that's why there are undefined variable
s
<?php
$id_user = $_GET['id_user'];
$b_ref = $_GET['b_ref'];
?>
$("#nav").load('pages/nav.php?id_user=<?php echo $id_user?>&b_ref=<?php echo $b_ref?>')
Does your browser allow Cookies? I mean check your Browser configuration. And start the session handling on the server.
1°:
Test your to put session_start
in the archives user.inc.php
and booking.inc.php
.
2°:
HTML:
<table id="nav">
<tr>
<td class="update-ajax"><? include 'pages/nav.php'; ?></td>
</tr>
</table>
JS:
$(document).ready(function(){
setInterval(function() {
$("#nav tr td.update-ajax").load('pages/nav.php'); // change selector
}, 5000);
});
精彩评论