我有附加的代码。当我手动按 F5 刷新页面时,动态内容会丢失。刷新后如何保留列表 <foo> 内容?. 当我第一次加载页面时,我可以看到<li>
foo 。
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Mobile Web App</title>
<link href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header">
<h1>Page One</h1>
</div>
<div data-role="content">
<ul class="Offline" data-role="listview" data-inset="true" data-divider-theme="c">
<li class="Offlinediv" data-role="list-divider">Users Offline</li>
<li><a href="#page2">Page Two</a></li>
</ul>
<?php
//********
// Connect to the database
// left join users users and users online .
// while($column = mysql_fetch_array($data))
$column['userid']='ABBM'; // hardcode for testing
//{
//user status not known
if (!isset($_SESSION[$column['userid']])){
$_SESSION[$column['userid']]='offline' ;
?>
<script>
$(".Offline").append('<li class="<?php echo $column['userid'];?>"><a href="#page">foo</a></li>');
$(".Offline").listview('refresh');
</script>
<?php
}
//else statement
//the code is not complete
// }
?>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>