Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery fullcalendar不显示事件_Javascript_Jquery_Fullcalendar_Jayrock - Fatal编程技术网

Javascript Jquery fullcalendar不显示事件

Javascript Jquery fullcalendar不显示事件,javascript,jquery,fullcalendar,jayrock,Javascript,Jquery,Fullcalendar,Jayrock,看到像fullcalendar这样的日历插件,我非常激动。我正在尝试使用fullcalendar显示每个月的事件。但这些事件不会显示在日历上 我的代码是: [AcceptVerbs(HttpVerbs.Get)] public JsonResult HighlightCalendar() { var tasksList = new List<HighlightMonthlyEvents>(); tasksList.Add(new HighlightMonthlyEv

看到像fullcalendar这样的日历插件,我非常激动。我正在尝试使用fullcalendar显示每个月的事件。但这些事件不会显示在日历上

我的代码是:

[AcceptVerbs(HttpVerbs.Get)]
public JsonResult HighlightCalendar()
{
    var tasksList = new List<HighlightMonthlyEvents>();

    tasksList.Add(new HighlightMonthlyEvents
    {
        id = 1,
        EventName = "Google search",
        EventStartDate = ToUnixTimespan(DateTime.Now),
        EventEndDate = ToUnixTimespan(DateTime.Now.AddHours(4)),
        url = "www.google.com"
    });
    tasksList.Add(new HighlightMonthlyEvents
    {
        id = 1,
        EventName = "Bing search",
        EventStartDate = ToUnixTimespan(DateTime.Now.AddDays(1)),
        EventEndDate = ToUnixTimespan(DateTime.Now.AddDays(1).AddHours(4)),
        url = "www.bing.com"
    });

    var highlightDays = Jayrock.Json.Conversion.JsonConvert.ExportToString(tasksList.ToArray());

    return Json(highlightDays, JsonRequestBehavior.AllowGet);
}


 <script type="text/javascript">
 $(function () {

// FullCalendar

$('.fullcalendar').fullCalendar({
theme: true,
header: {
 left: 'today prev,next',
 center: '',
 right: ''
},
defaultView: 'month',
editable: false,
events: function (callback) {
 // do some asynchronous ajax
 contentType: "application/json; charset=utf-8",
        $.getJSON("/Test/HighlightCalendar/", null,
               function (result) {
                var calevents = new Array();
                var results = eval(result);
                eval(results.length);
                if (results != null) {
                 for (i in results) {
                  var calEvent = results[i];

                  calevents.push(calEvent)

                 }
                }
                alert(calevents.length);

                // then, pass the CalEvent array to the callback
                callback(calevents);

               });
}

});

您认为哪里不对?

这可能与您的属性和值周围的引号有关

尝试在属性和值中包含引号,并检查结果

我在没有像这样使用JSON.js的情况下实现了同样的效果

System.Web.Script.Serialization.JavaScriptSerializer eventListSerializer =
                                                                                    new System.Web.Script.Serialization.JavaScriptSerializer();
                string eventListJSON = eventListSerializer.Serialize(addevList);

这可能与属性和值周围的引号有关

尝试在属性和值中包含引号,并检查结果

我在没有像这样使用JSON.js的情况下实现了同样的效果

System.Web.Script.Serialization.JavaScriptSerializer eventListSerializer =
                                                                                    new System.Web.Script.Serialization.JavaScriptSerializer();
                string eventListJSON = eventListSerializer.Serialize(addevList);