1

这是我的代码。它适用于获取数据和解析,但我无法显示事件。请让我知道可能的原因。

我觉得回调(事件)在这里不起作用。

 events: function(callback)
                {
                    $.ajax({
                        type: "POST",
                        url: "WebService.asmx/hello",
                        data: "{}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function(data)
                        {
                            var evnt = [];
                            $(data.d).find('event').each(function()
                            {

                                evnt.push({
//                                    title: $(this).attr('title'),
//                                    start: $(this).attr('start'),
                                //                                    end: $(this).attr('end')
                                       title: 'Events1',
                                       start: '2010-04-01',
                                       end: '2010-04-10'
                                });

                            });
                              alert('called end');
                            callback(evnt);

                        },
                        error: OnError
                    });
                }
4

3 回答 3

0

我写了一个示例,说明如何使用 Web 服务让 FullCalendar 在 ASP.NET 中工作。

http://jake1164.blogspot.com/2010/06/jquery-fullcalendar-and-aspnet.html

于 2010-07-21T19:48:07.447 回答
0

我遇到了这个问题,无论我如何修饰 .asmx 文件中的类或方法,我都会得到 XML 作为结果。我终于找到了一个链接,它帮助我创建了一个标准的 .aspx 页面。.aspx 文件如下所示:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ScheduledEvents.aspx.cs" Inherits="ScheduledEvents" %>

我的 .aspx.cs 文件是这样的:

public partial class ScheduledEvents : System.Web.UI.Page
{
 protected override void Render(HtmlTextWriter writer)  
 {
   List<Event> itemList = new List<Event>();
   for (int i = 0; i < 5; ++i)
   {
        Event newEvent = new Event();
        newEvent.id = i;
        newEvent.className = "";
        newEvent.title = "Test";
        newEvent.start = (((int)DateTime.Now.AddDays(i).ToUniversalTime().Subtract(Event.rootTime).TotalSeconds)).ToString();
        newEvent.end = (((int)DateTime.Now.AddDays(i).AddMinutes(60).ToUniversalTime().Subtract(Event.rootTime).TotalSeconds)).ToString();
        newEvent.url = "http://www.google.com";
        newEvent.allDay = false;
        itemList.Add(newEvent);
   }
   Response.Clear();
   Response.ContentType = "application/json";
   Response.Write(new JavaScriptSerializer().Serialize(itemList.ToArray()));  
 }
}

你可以猜到 Event 类的构成,但它看起来像这样:

public class Event
{
  public static readonly DateTime rootTime = DateTime.Parse("1970-01-01 00:00:00");
  public int id = default(int);
  public string className = string.Empty;
  public string title = string.Empty;
  public string start = string.Empty;
  public string end = string.Empty;
  public string url = string.Empty;
  public bool allDay = false;
}

完整日历使用自 1970 年 1 月 1 日以来的秒数,因此使用“rootTime”。此外, startDate 和 endDate 被转换为 int 以修剪小数位,这是 Full Calendar 不喜欢的。

于 2010-10-01T12:54:52.683 回答
0

我相信start并且end需要成为 Date 对象

title: 'Events1',
start: new Date(2010, 4, 1),
end: new Date(2010, 4, 10)

请参阅文档:http ://arshaw.com/fullcalendar/docs/event_data/Event_Object/

于 2010-04-19T19:38:58.763 回答