Fullcalendar /获取JSON提要(已编辑)

时间:2012-09-09 13:34:20

标签: c# asp.net json jquery fullcalendar

我在使用ajax从我的JSON提要中获取数据时,我的fullCalendar对象中的事件没有显示。我相信JSON格式是正确的,因为JSON.aspx的输出是:

[{ “ID”:1, “标题”: “TESTTITLE”, “信息”: “INFOINFOINFO”, “启动”: “2012-08-20T12:00:00”, “端”:“2012- 08-20T12:00:00" , “用户”:1}]

我使用的是Firebug,看起来JSON Feed无法正常获取?

当我在正确显示的事件中直接添加上层JSON-feed时。

(编辑)JSON响应现在正在运行,但事件仍未显示在fullcalendar中。

JSON.aspx

public partial class JSON : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
    // Get events from db and add to list.
    DataClassesDataContext db = new DataClassesDataContext();
    List<calevent> eventList = db.calevents.ToList();

    // Select events and return datetime as sortable XML Schema style.
    var events = from ev in eventList
                 select new
                 {
                     id = ev.event_id,
                     title = ev.title,
                     info = ev.description,
                     start = ev.event_start.ToString("s"),
                     end = ev.event_end.ToString("s"),
                     user = ev.user_id
                 };

    // Serialize to JSON string.
    JavaScriptSerializer jss = new JavaScriptSerializer();
    String json = jss.Serialize(events);

    Response.Write(json);
    Response.End();
   }
}

我的Site.master

<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />    
<link href='fullcalendar/fullcalendar.css' rel='stylesheet' type='text/css' />
<script src='jquery/jquery-1.7.1.min.js' type='text/javascript'></script>
<script src='fullcalendar/fullcalendar.js' type='text/javascript' ></script>
<script type="text/javascript">
     $(document).ready(function () {
         $('#fullcal').fullCalendar({

            eventClick: function() {
                alert('a day has been clicked!');
            },
          events: 'JSON.aspx' 
         })
     });
</script>

我已经扫描了几天的相关问题,但似乎没有人能解决我的问题......

1 个答案:

答案 0 :(得分:2)

为什么你的电话如此复杂?现在试试这个:

$('#fullcal').fullCalendar({     
    events: 'JSON.aspx',
    eventClick: function (calEvent, jsEvent, view) {
        alert('a day has been clicked!');
    }
});