【发布时间】:2011-11-17 23:41:09
【问题描述】:
我正在使用 David Walsh's calendar 函数在 WordPress 主题中创建活动日历。我想在使用 AJAX 的月份之间移动,但我不熟悉并且无法发布和获取月份和年份变量。我引用了这个AJAX video tutorial。
在页面模板的顶部,我有这个功能:
function swapContent(month,year) {
jQuery("#calendar").html("<img src='images/ajax-loader.gif'>").show();
var url="calendar.php";
jQuery.post(url, {contentVar: month, year}, function(data){
jQuery("#calendar").html(data).show();
});
}
在calendar.php中:
$month = (int) ($_GET['month'] ? $_GET['month'] : date('m'));
$year = (int) ($_GET['year'] ? $_GET['year'] : date('Y'));
$contentVar = $_POST['month']['year'];
我的上/下个月控件如下所示:
$previous_month_link = '<a href="?month='.($month != 1 ? $month - 1 : 12).'&year='.($month != 1 ? $year : $year - 1).'" class="control" onClick="return false" onmousedown="javascript: swapContent("month", "year")">Previous Month</a>';
我所有的 calendar.php 文件都在这里:http://pastebin.com/R9zpA3yM
提前致谢,非常感谢任何帮助。
【问题讨论】: