Ok, so I've looked through documentation and Googled this, yet surprisingly I can't find a solution and nobody seems to be having the same trouble I am. I am fairly new to JQuery AJAX, and I am putting together a sort of booking calendar from scratch and I am looking for a way to highlight elements or "dates" in the calendar GUI based on whether that "date" has bookings in the database. Here's the block of JQuery I'm tinkering with, but I feel like I'm way off for some reason.
$(".box").load(function() {
date_time = $(this).attr('id');
month = $(this).attr('month');
year = $(this).attr('year');
$.ajax({
type: 'GET',
url: '/book.me/check.php',
data: "date=" + date_time + "&month=" + month + "&year=" + year,
success: function(msg) {
$(this).css("background-color", "#cccccc");
}
});
});
Any help would be appreciated, thanks.
addClassto add it:.addClass("highlight"). That way you can easily find all highlighted cells. For instance, if you wanted to remove the highlighting on all the highlighted cells you could do something like$(".box.highlight").removeClass("highlight");