事件作为json feed

时间:2017-09-26 13:47:39

标签: asp.net json fullcalendar

我指向一个生成json字符串的aspx(Events_json.aspx)页面。这是代码:

        $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        buttonText: {
            today: 'today',
            month: 'month',
            week: 'week',
            day: 'day'
        },
        events: 'Events_json.aspx',
        editable: true,
        droppable: true
      }  //etc.

我的aspx页面有以下指令:

<%@ Page ContentType="application/json" ResponseEncoding="utf-8" Language="VB" AutoEventWireup="false" CodeFile="Events_json.aspx.vb" Inherits="Events_json" %>

我的子例程使用response.write写出事件数据:

                Do While dr.Read()
                EventID = dr("EventID")
                EventST = dr("EventST")
                EventET = dr("EventET")
                EventName = dr("EventName")
                ECBgColor = dr("ECBgColor")
                ECBdrColor = dr("ECBdrColor")
                str = str & "        {" & vbCrLf
                str = str & "            id: '" & EventID.ToString() & "'," & vbCrLf
                str = str & "            title: '" & ToHex(EventName) & "'," & vbCrLf
                str = str & "            start: '" & Format(EventST, doDate(EventST) + "T" + "HH:mm:ss").ToString() & "'," & vbCrLf
                str = str & "            end: '" & Format(EventET, doDate(EventET) + "T" + "HH:mm:ss").ToString() & "'," & vbCrLf
                str = str & "            backgroundColor: '" & ECBgColor.ToString() & "'," & vbCrLf
                str = str & "            borderColor: '" & ECBdrColor.ToString() & "'" & vbCrLf
                str = str & "        }," & vbCrLf
            Loop
            str = str.Substring(0, str.Length - 3) & vbCrLf
            'str = str & "    }" & vbCrLf
            'str = str & "]," & vbCrLf
            Response.Write(str)

当我运行此页面时,它会生成一个json字符串,但FireFox告诉我存在语法错误:SyntaxError:JSON.parse:期望的属性名称或者&#39;}&#39;在JSON数据的第2行第13行

当我运行包含FullCalendar脚本的页面时,不会显示任何事件。当我将events_json.aspx的输出复制并粘贴到FullCalendar脚本中时,事件会显示在日历上。

{
            id: '1',
            title: 'Test Event',
            start: '2017-9-25T10:00:00',
            end: '2017-9-25T11:00:00',
            backgroundColor: '#3c8dbc',
            borderColor: '#3c8dbc'
        },
        {
            id: '2',
            title: 'Test Event',
            start: '2017-9-26T10:00:00',
            end: '2017-9-26T11:00:00',
            backgroundColor: '#3c8dbc',
            borderColor: '#3c8dbc'
        },
        {
            id: '3',
            title: 'Test Event',
            start: '2017-9-27T10:00:00',
            end: '2017-9-27T11:00:00',
            backgroundColor: '#3c8dbc',
            borderColor: '#3c8dbc'
        }

我不明白为什么我对外部页面的调用不会显示事件,但是当我将外部页面的输出复制并粘贴到我的日历脚本中时,它可以正常工作。有人可以帮忙吗?谢谢!

0 个答案:

没有答案