这是加载下一页和上一页的ajax request
$sCalendarItself = strtr(file_get_contents('templates/calendar.php'), $aKeys);
// AJAX requests - return the calendar
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
&& isset($_GET['month']))
{
header('Content-Type: text/html; charset=utf-8');
echo $sCalendarItself;
exit;
}
$aVariables = array(
'__calendar__' => $sCalendarItself,
);
echo strtr(file_get_contents('templates/index.php'), $aVariables);
?>
这是模板文件夹中的calendar.php
<div class="navigation">
<a class="prev" href="#calendar?month=__prev_month__" onclick="$('#calendar').load('foodcalendar.php?month=__prev_month__&_r=' + Math.random()); return false;"></a>
<div class="title" >__cal_caption__</div>
<a class="next" href="#calendar?month=__next_month__" onclick="$('#calendar').load('foodcalendar.php?month=__next_month__&_r=' + Math.random()); return false;"></a>
</div>
这是模板文件夹中的index.php
<div id="calendar">
__calendar__
</div>
当我点击下个月的链接时,它将使用整个页面html元素加载下个月的日历。我只想加载该日历div并仅显示该特定div中的下个月日历