0

私のサーバーのサイドページ(getEvents.cfm)から次の文字列を返しています。私はColdFusionで働いています。myfeeds.php(サーバー側)から返すもの

[ 
{ 
    title: 'Event1', 
    start: '2012-02-02', 
    end: '2012-02-02', 
    allDay: 'no' 
}, 
{ 
    title: 'Event2', 
    start: '2012-02-03', 
    end: '2012-02-03', 
    allDay: 'no' 
} 
] 

ただし、イベントを取得中にエラーが発生しました。ページの読み込みにエラーが発生しました。ここで

私はイベントを取得するために使用していたコードです:すべてのallDay

eventSources: [ 

      // your event source 
      { 
       url: '../getevents.cfm', 
       type: 'POST', 
       data: { 
        custom_param1: 'something', 
        custom_param2: 'somethingelse' 
       }, 
       error: function() { 
        alert('there was an error while fetching events!'); 
       }, 
       color: 'yellow', // a non-ajax option 
       textColor: 'black' // a non-ajax option 
      } 

      // any other sources... 

] 

答えて

2

まずはい/いいえではない真/偽でなければなりません。第二に、戻り値の文字列は次のようになります。

[{ 
    "title": 'Event2', 
    "start": '2012-02-03', 
    "end": '2012-02-03', 
    "allDay": 'false' 
}] 
+0

アディル、ええ、JSONオブジェクトは文字列で囲まれたキーと値の両方を持っている必要があることを忘れないでください。 http://json.org/example.html –

+0

ありがとうございました。 私はjSonを初めて使用しています。私はフォーマットを見つけました: http://arshaw.com/fullcalendar/docs/event_data/Event_Source_Object/ 彼らは間違ったjSonフォーマットを提供しているかもしれません。 もう一度お返事ありがとうございます –

+0

はい、大文字と小文字の区別を保持するためにキーを引用する必要があります。そうでない場合は、大文字と小文字の区別が必要です –

0
$.getJSON('path_to_your_json_file',function(data){ 
    $.each(data,function(index,entry){ 
     //assuming we already have a <div> created and get the id 
     //show the JSON data 
     $('#div_id_created_earlier').append(' 
     'Title: ' + entry.title + '<br \/>' + 
     'Start: ' + entry.start + '<br \/>' + 
     'End: ' + entry.end + '<br \/>' + 
     'All day: ' + entry.allDay + '<br \/><br \/>' + 
     '); 
    }); 
}); 
関連する問題