php - 更改选择选项值时网页上偶尔显示白色空白

标签 php html css jquery

我正在构建一个在线系统,其中的用户是某所大学机构的讲师。该系统的主要功能之一是让用户能够通过互联网查看他们的日程安排。

我目前正在构建用户查看其日程安排的页面,我所做的是在其中创建一个选择选项,该选项在值更改时触发 jquery 函数(执行 ajax 请求)。然后,请求的页面显示在当前页面的一个 div 上。

问题是,当我尝试更改选择选项的值时,页面偶尔会在我的整个页面顶部显示一个巨大的白色空白。我不知道是什么触发了这个错误,因为它只是偶尔发生,而不是每次都发生。当我重新加载页面时,空白区域消失了。

我一直在到处寻找答案,但没有找到适合我问题的答案。

这是出现空白之前的页面 https://lh6.googleusercontent.com/-rb0XXjcpn6w/UPiwjIY92OI/AAAAAAAAABo/BmiDIbZWcxU/s640/before.jpg

这是空白出现时的页面 https://lh3.googleusercontent.com/-RZxh2P3Bk0o/UPiwRv5oHHI/AAAAAAAAABc/VIB6LYvPBE4/s640/after.jpg

希望大家能帮帮我...

这是页面的代码..

<?php
require_once("../includes/initialize.php");

 $adminEmps = employee::find_by_cond("(department = 'ACADEMIC-TEACHING' or department = 'ACADEMIC-NON TEACHING') and emp_status='active' order by lastname asc");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Schedule</title>
</head>
<script type="text/javascript">
function selectEmp(){
$('#here').html("<img src=../Images/gif/loading14.gif' class='three columns     centered'>");
$.post('viewSched.php','id='+$('#selector').val()+'&yr='+$('#yrselect').val(),
    function (response){
      $('#here').html(response);
    });
}
</script>
<body>
<?php include("AdminDropdown.php"); ?>
<div class="row">
 <div class="twelve columns">
<div class="row panel">
    <h2><img src="../Images/Shedule.png" height="100px" width="100px" style="vertical-align:middle"/>
        Schedule
    </h2>
    <dl class="tabs pill">
      <dd class="active"><a href="#simple1">Academic</a></dd>
      <dd><a href="#simple2">Administrative</a></dd>
      <dd class="hide-for-small"><a href="#simple3">OSAS</a></dd>
    </dl>
  </div>
 <ul class="tabs-content">
<li class="active" id="simple1Tab">
<div class="two columns">
  Select Employee 
</div>
<div class="three columns end">
  <select id='selector' onchange="selectEmp()" >
    <option>--Select--</option>
   <?php
    foreach ($adminEmps as $key => $value) {
      echo "<option value={$value['emp_ID']}>{$value['lastName']},     {$value['firstName']} {$value['lastName']}</option>";
    }
   ?>
  </select>
</div>
<div class='two columns'>
</div>
<div class='two columns' style='text-align:right;'>
  Select Year
</div>
<div class='three columns end'>
  <select id='yrselect' onchange="selectEmp()">
    <option>-- Select --</option>
    <?php
      for ($i=2008; $i <= date('Y'); $i++) { 
        $yr = $i + 1;
        echo "<option>{$i}-{$yr}</option>";
      }
    ?>
  </select>
</div>
<br>
<br>
<div class="twelve columns ">
  <div class="nine columns centered">
    <div id='here'>

  </div>
  </div>
</div>

</li>
<li id="simple2Tab"></li>
<li id="simple3Tab">This is simple tab 3s content.</li>
</ul>   

</div>
</div>


<?php include("adminfooter.php"); ?>
</body>
</html>

这是请求页面的代码。

<?php
require_once('../includes/initialize.php');

    $id = $_POST['id'];
    $yr = $_POST['yr'];
        $info = sched::find_scheds_by_id_yr($id,$yr);
        $display = "<table>
                        <thead>
                        <tr>
                            <th>Day</th>
                            <th>Time Start</th>
                            <th>Time End</th>
                            <th>Room</th>
                            <th>Subject</th>
                        </tr>
                        </thead>
                        <tbody>

                        ";
                    if($info){
        foreach ($info as $key2 => $value2) {
            $display .= "<tr>
                        <td>".$value2['day']."</td>
                        <td> ".$value2['time_start']."</td>
                        <td>{$value2['time_end']}</td>
                        <td>{$value2['room']}</td>
                        <td>{$value2['Subject_description']}</td>
                        </tr>";
        }
    }
            $display.="</tbody>
                    </table>";


?>
<html>
<head><title></title></head>
<body>
    <?php echo $display; ?>
</body>
</html>

顺便说一句,这只发生在谷歌浏览器中。

最佳答案

根据您的源文件,唯一可见的 javascript 将 #here div 的内容更改为 img 中的加载图像标记,或 AJAX 调用的结果。

因为除了这个 div 似乎什么都没有改变,你应该看看 css 看看它是否正确地处理了一个带有动态内容的 div (即,一个div 其内容将改变大小)。

查看它的定位/大小,以及您如何处理 overflow 属性。

关于php - 更改选择选项值时网页上偶尔显示白色空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14391468/

相关文章:

PHP fatal error : Interface 'JsonSerializable' not found

php - 使用 cURL 登录站点

php - TCPDF 如何设置标题中的上边距

html - 在 HTML 中,如何在 li 之前抑制 ul 之后的换行

javascript - 无法在 Firefox 中设置默认焦点

javascript - 如何使可折叠的侧边栏变粘?

css - 如何格式化最近点击的链接

javascript - FullCalendar 列出一天的事件模式

html - 在网站上居中图标

html - 响应式网页设计的列表元素位置