找了半天的資料,,都是php的,,在自己的項(xiàng)目中做了一個(gè)java ajax加載后臺日程的jquery,核心代碼如下:
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month'
},
selectable: true,
//selectHelper: true,
select: function(start, end, allDay) {
//選中某一日期觸發(fā)事件
start = $.fullCalendar.formatDate(start,"yyyy-MM-dd");
$("#actionTime",window.opener.document).val(start);
findFilm('t');
$("#ticketMenuDiv").show();
$("#returnButt").show();
$("#timeList").hide();
},
//點(diǎn)擊日程觸發(fā)事件
eventClick: function(calEvent, $event){
date = $.fullCalendar.formatDate(calEvent.start,"yyyy-MM-dd");
$("#actionTime",window.opener.document).val(date);
findFilm('t');
$("#ticketMenuDiv").show();
$("#returnButt").show();
$("#timeList").hide();
},
events: function() {
$("#calendar").fullCalendar('removeEvents'); //清空上次加載的日程
$.ajax({
type: "POST",
data: "m=queryfilmname",
url: "<%=request.getContextPath()%>/seatMap",
success: function (data){
//請求成功,返回byte數(shù)組
var menus = data.split("<+>");
var area = menus[1].split("<=>");
for(var i = 1; i < area.length; i++){
var nextDate = area[i].split("<->")[0];
//日期轉(zhuǎn)化成date類型
var myDate= new Date(Date.parse(nextDate.replace(/-/g, "/")));
var obj = new Object();
obj.title = area[i].split("<->")[1];
obj.start = myDate;
$("#calendar").fullCalendar('renderEvent',obj,true);//把從后臺取出的數(shù)據(jù)進(jìn)行封裝以后在頁面上以fullCalendar的方式進(jìn)行顯示
}
},
error:function (){
alert("服務(wù)器異常,請聯(lián)系管理員,!");
}
});
}
});
//后臺servlet方法
private void queryfilmname(HttpServletRequest req, HttpServletResponse resp,
SeatMapService service) throws Exception {
Map<String, String> map = new HashMap<String, String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
map.put("FLIGHT_TIME", sdf.format(new Date()));
List<MenuName> menuList = service.getMenuList(map);
StringBuffer res = new StringBuffer();
res.append("<+>");
if(menuList!=null && menuList.size()>0){
for(MenuName menu :menuList){
res.append("<=>");
res.append(menu.getFlightDate());
res.append("<->");
res.append(menu.getRouteName());
}
}
resp.getOutputStream().write(res.toString().getBytes("utf-8"));
}
|