如果这是一个简单的解决方法,我深表歉意,我对 jquery 有点陌生。首先,我不认为这是我最初的调用搞砸了,因为如果我放入一个简单的警报函数,它会在点击时正常工作,基本上当<li>
点击它时,jquery 会触发一个 ajax 到 php 函数发送类到<li>
php 脚本并返回,打开带有结果的警报。据我所知,它应该可以工作,但我的知识还是相当有限的。任何更改任何人都可以看看我有什么,看看你是否可以清理它,目前点击时没有任何反应,控制台中甚至没有出现错误。但我想即使是我的 ajax 调用也是错误的。任何想法为什么点击时什么都没有发生?
HTML:
<li title = "Previous Month" id = "changeMonthBack" class = "<?php echo date('n'); ?>"><img src="images/leftArrow.gif" width="54" height="45" alt="previous month"></li>
jQuery/javascript:
//javascript document
$(document).ready(function(){
//need to do an onclick for getting the new month(previous)
$(".changeMonthBack").click(function(){
function calendar(){
//set the id for php
var identifier = 1;
//get the class to use for month
var str = document.getElementById("changeMonthBack").class;
//get the month number
//if the month is 1, we obviously need it to be 12
if str == 1{
var month = 12;
}
else{
var month = str - 1;
}
$.post("redraw.php"),{
identifier: identifier,
month: month
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
};
})//end function 1
});