Fullcalendar /抓取JSON提要(编者) [英] Fullcalendar/Fetching JSON feed(Edited)

查看:197
本文介绍了Fullcalendar /抓取JSON提要(编者)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem with the events in my fullCalendar object not showing when using ajax to fetch the data from my JSON feed. I believe the JSON format is proper though since the output from JSON.aspx is:

[{\"id\":1,\"title\":\"TESTTITLE\",\"info\":\"INFOINFOINFO\",\"start\":\"2012-08-20T12:00:00\",\"end\":\"2012-08-20T12:00:00\",\"user\":1}]

[{"id":1,"title":"TESTTITLE","info":"INFOINFOINFO","start":"2012-08-20T12:00:00","end":"2012-08-20T12:00:00","user":1}]

我用萤火虫,它似乎像JSON提要没有得到正确牵强?

I used Firebug and it seems like the JSON feed is not getting fetched properly?

当我直接在事件添加上JSON饲料它显示正常。

When I add the upper JSON-feed directly in the events it displays properly.

(编辑)的JSON响应现在的工作,虽然事件仍然没有fullcalendar显示。

JSON.aspx

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母

And my 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>

我已经扫描相关的问题了好几天,但他们都不似乎解决我的...

I've been scanning related questions for days but none of them seems to fix mine...

推荐答案

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

Why are your calls so complicated? Try this for now:

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

这篇关于Fullcalendar /抓取JSON提要(编者)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆