Hi all,
I am using "fullcalendar 1.4.7" in my application to display a shared calendar. My backend is in Java. My javascript looks like this:
$(document).ready(function() {
if (!this.JSON) {
this.JSON = {};
}
alert($('#sampleData').val());
$('#mycalendar').fullCalendar({
// put your options and callbacks here
header: {
left: 'prevYear,prev,next,nextYear today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: JSON.parse($('#sampleData').val())
});
I am creating JSON event objects in my servlet and am trying to display these events on the browser. My servlet does this:
SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
JSONObject testObj1 = new JSONObject();
testObj1.put("title", "json event test1");
testObj1.put("start", sdf.format(today));
testObj1.put("end", sdf.format(end));
JSONObject testObj2 = new JSONObject();
testObj2.put("title", "json event test2");
testObj2.put("start", sdf.format(today));
testObj2.put("end", sdf.format(end2));
JSONArray eventsArray = new JSONArray();
eventsArray.add(testObj1);
eventsArray.add(testObj2);
resp.sendRedirect("jsp/MyCalendarJsp.jsp?events="+eventsArray.toString());
I am using a hidden input variable in html to fetch the events array in my JSP:
<% String events = (String)request.getParameter("events");
if(events!=null && !events.isEmpty())
{
%>
<input type="hidden" id="sampleData" name="sampleData" value='<%= events%>'/>
<%} %>
<table border="1" width="75%" align="center">
<tr>
<td>
<div id='mycalendar'></div>
</td>
</tr>
</table>
The above code works fine on IE 7 and 8. However, the events are not displayed in firefox and google chrome.
Does anyone know why this is happening? I need this calendar to work on IE, firefox and Google Chrome!
P.S: I have included the css in my jsp. Also, the alert in my javascript displays the value set in my servlet in all the browsers. So, I know that I have the data in my JSP.