2010-06-16 126 views
1

我试图从MySQL数据库显示我的事件。我正在使用事件功能。我返回的XML文件非常基础。我查看了所有FullCalendar问题,其中大部分都讨论JSON并指向JSON的文档。我无法使用JSON。我必须去XML。你能告诉我我在哪里吗?FullCalendar和事件:函数

这里是什么我的XML看起来像一个示例:

<id><id> 
<title>Grow Your Business on the Web</title> <br> 
<start>2010-06-05T9:30</start> <br> 
<end>2010-06-05T12:30</end> <br> 
<className>O</className> <br> 
<url></url> 

整个文件是以一<event>标签,并用</event>标签关闭。

我jQuery是如下:

$(document).ready(function() { 

    $('#calendar').fullCalendar({ 
    height: 550, 
    theme: true, 
    header: { 
      left: 'prev,next today', 
     center: 'title', 
     right: 'month,agendaWeek,agendaDay' 
     }, 
    editable: true, 
    events: function(start, end, callback) { 

    $.ajax({ 
     url: 'ncludeFiles/sbdp-cal-xml.php', 
     dataType: 'xml', 
     data: { 
     // our hypothetical feed requires UNIX timestamps 
     start: Math.round(start.getTime()/1000), 
     end: Math.round(end.getTime()/1000) 
     }, 
     success: function(doc) { 

     var events = []; 

      $(doc).find('event').each(function() { 
       events.push({ 
        title: $(this).attr('title'), 
        start: $(this).attr('start'), 
        end: $(this).attr('end'), 
        className: $(this).attr('className'), 
        url: $(this).attr('url') 
       }); 
      }); 

      callback(events); 
     } 
    }); 
     } 
    }); 
}); 

我会很感激任何帮助,您可以给我。谢谢!

回答

0

示例代码也不适用于我。试试这个:

$.ajax({ 
url: 'pathto/myxmlfeed.php', 
data: "start="+Math.round(start.getTime()/1000)+"&end="+Math.round(end.getTime()/1000)+"&_rand="+Math.floor(Math.random()*100), 
success: function(doc) { 
    var events = []; 
    $(doc).find('event').each(function() { 
     events.push({ 
     title: $(this).attr('title'), 
     url: $(this).attr('url'), 
     start: $(this).attr('start') // will be parsed 
     }); 

     }); 

     callback(events); 
    } 
    }); 

在您myxmlfeed.php你可以做一个$ _GET拉开始日期和结束日期查询您的数据库时使用。该XML的结构应该是这样的:

<xml> 
<event id="1" title="first entry" url="http://www.google.com" start="2010-07-22" /> 
</xml> 

你还需要到的jquery.js更改为1.3.2版本,1.4.2不正确的IE8工作。

0

上面的代码给了我错误,因为“回调不是一个函数”。
我换成这行 -

events: function(start, end, callback) { 

events: function(start, end, timezone, callback) { 

它开始工作。