JavaScript 新手。在过去的几天里,我学到了很多东西。
我有一个加载日历的脚本。日历布局是用 php 构建的。我有以下代码:
jQuery.get(PLUGIN_DIR+'/bookings/reservation.php', function(data)
{
jQuery('#content_div').html(data);
});
预订.php
<?php
echo '</div><div class="box_div" id="reservation_div"><div class="box_top_div" id="reservation_top_div"><div id="reservation_top_left_div"><a href="." id="previous_week_a">< Previous week</a></div><div id="reservation_top_center_div">Reservations for week <span id="week_number_span">' . global_week_number . '</span></div><div id="reservation_top_right_div"><a href="." id="next_week_a">Next week ></a></div></div><div class="box_body_div"><div id="reservation_table_div"></div></div></div><div id="reservation_details_div">';
?>
以上工作正常。但是,当我添加以下包含来定义 global_week_number 它停止工作。
<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/bookings/js/header-js.php');
echo '</div><div class="box_div" id="reservation_div"><div class="box_top_div" id="reservation_top_div"><div id="reservation_top_left_div"><a href="." id="previous_week_a">< Previous week</a></div><div id="reservation_top_center_div">Reservations for week <span id="week_number_span">' . global_week_number . '</span></div><div id="reservation_top_right_div"><a href="." id="next_week_a">Next week ></a></div></div><div class="box_body_div"><div id="reservation_table_div"></div></div></div><div id="reservation_details_div">';
?>
包含文件是 header-js.php:
<script type="text/javascript">
<?php
echo "PLUGIN_DIR = '".plugins_url()."';";
echo "global_css_animations = ".global_css_animations.";";
echo "global_week_number = ".global_week_number.";";
?>
</script>
我在这里不知所措。我不知道为什么当我包含 header-js.php 时它会停止工作。任何的想法?
谢谢。