G'Day 所有,
我正在尝试使用 jQuery $.post 函数将一些参数传递给 PHP 文件,该文件:
从 MySQL 数据库收集航班预订信息,
生成带有数据的 HTML 表单以供显示,
将 HTML 输出返回到隐藏的
<div>
,取消隐藏
<div>
,使其作为一种对话框位于页面其余内容的顶部。
问题是,如果我有<div id="bookingpop" style="display:none; ... ">
.show() 在用于插入和显示 php 文件输出的 jquery 行中不显示(取消隐藏)<div>
. (??)
作为测试:
如果我取出“显示:无;” 始终显示 div 的样式(如下面的 HTML 代码的状态),输出通过 $.post 从 PHP 填充元素可以正常工作,但它显然总是存在(不受欢迎)。
$("#bookingpop").hide() 如果可见(再次作为测试),则不会隐藏它,
如果允许运行,我在违规行 (
alert(bid);
和alert(output);
) 下方评论的其他内容都按预期运行和显示。日期选择器也可以正常工作。
#bookingpop 的开始标签和结束标签之间是否有 HTML 注释
<div>
对问题没有影响,IE8-9、FF10、Chrome、iPad 3 上的 Safari,除了 IE 解释表单字段宽度比其他宽度更宽之外没有区别。
标头中的 JS/jQuery:
<script type="text/javascript">
function passbooking(bid) { // <- bid is the Booking ID
$.post("bookdisplay.php", { bookref: bid },
function(output) {
$("#bookingpop").html(output).show();
// alert(bid);
// alert(output);
});
};
/* Code for th jQuery-ui date picker. */
$(function() {
// $("#bookingpop").hide();
$( "#pick_DATE" ).datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: "yy-m-d"
});
});
</script>
HTML/PHP:
<div style="position: absolute; top: 0px; left: 0px; height: 124px; width: 157px; border: none; margin: 0;"><img alt="Logo" src="/act/images/avncol-logo.png" />
</div>
<div style="position:absolute; left: 157px; top:0px; width: 1000px; height: 64px; border: none;">
<h2>Aviation College Townsville: Daily Run Sheet</h2>
</div>
<div style="position: absolute; top: 65px; left: 157px; height: 64px; width: 1000px;"><input type="text" id="pick_DATE" size="20" value="<?php echo $date ?>"/></div>
<?php
$booking_overlays = prepevents($date);
// var_dump($booking_overlays);
?>
<div class="parentDiv" style="top: 126px; left: 0px;"> <!-- create a parent div section to contain and reference the timeline <div> elements to -->
<?php
print $timesheet; // Prints a grid/daily planner made from <div> elements
print $booking_overlays; // Prints a event/bookings as time blocks over the planner (as <div>)
?>
</div> <!-- Close the "parentDiv" -->
<!-- This div is the one that pops up over the others to display the booking -->
<div id="bookingpop" style="position: absolute; z-index: 100; background-color:#FFF; left: 200px; top: 50px; width: 610px; height: 500px; border: 3px solid; margin: 0;"><!-- the data goes in here --></div>
</body>
</html>
我是 JS/jQuery 的新手,并且正在重新学习 HTML(自从 CSS 存在并且 JS 很普遍之前就没有接触过它)。如果有人能看到任何不合适的地方(或根本是错误的),请告诉我。