4

here am trying to get reccurring events from calendar list with the help of SPServices i have a code as shown bellow,but when am using the bellow code it is giving me erroe as

"https://MYURL/Scripts/jquery-1.9.1.min.js Failed to load resource: the server responded with a status of 500 (Internal Server Error)send @ jquery-1.9.1.min.js:5"
and it also shows WARNING as

"jquery-1.9.1.min.js:5 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/."

 $(document).ready(function () {         
            var start = new Date();
            $().SPServices({
                operation: "GetListItems",
                async: false,
                listName: "ListName",
                CAMLViewFields: "<ViewFields>" +
                          "<FieldRef Name='Title' />" +
                          "<FieldRef Name='EventDate' />" +
                          "<FieldRef Name='EndDate' />" +
                          "<FieldRef Name='Location' />" +
                          "<FieldRef Name='Description' />" +
                          "<FieldRef Name='fRecurrence' />" +
                          "<FieldRef Name='RecurrenceData' />" +
                          "<FieldRef Name='fAllDayEvent' />" +
                      "</ViewFields>",
                CAMLQuery: '<Query>' +
                      '<CalendarDate>' + start + '</CalendarDate>' +
                      '<Where>' +
                          '<DateRangesOverlap>' +
                          '<FieldRef Name="EventDate" />' +
                          '<FieldRef Name="EndDate" />' +
                          '<FieldRef Name="RecurrenceID" />' +
                          '<Value Type="DateTime">' +
                              '<Year />' +
                          '</Value>' +
                          '</DateRangesOverlap>' +
                      '</Where>' + '<OrderBy>' +
                          '<FieldRef Name="EventDate" />' +
                      '</OrderBy>' +
                      '</Query>',
                CAMLQueryOptions: '<QueryOptions>' +
                          '<CalendarDate>' + start + '</CalendarDate>' +
                          '<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>' +
                          '<ExpandRecurrence>TRUE</ExpandRecurrence>' +
                      '</QueryOptions>',
                completefunc: function (xData, Status) {
                    var events = [];
                    //        alert(xData.responseXML.xml);
                    alert($(xData.responseXML).find("[nodeName=rs:data]").attr("ItemCount"));
                    $(xData.responseXML).find("[nodeName=z:row]").each(function () {
                        var fADE = $(this).attr("ows_fAllDayEvent");
                        if (fADE != null) {
                            if (fADE == 0) { thisADE = false }
                            else thisADE = true;
                        }
                        var thisID = $(this).attr("ows_ID");
                        var sepID = thisID.indexOf(';#');
                        if (sepID != -1) thisID = thisID.substring(0, sepID);
                        var thisTitle = $(this).attr("ows_Title");
                        var thisRecurrence = $(this).attr("ows_fRecurrence");
                        var thisDesc = $(this).attr("ows_Description");

                        if (thisID.length > 3) alert(thisTitle + ": " + thisID);
                        var thisUrl = "DispForm.aspx?ID=" + thisID + "&Source=FullCalendar.aspx";
                        var thisRD = $(this).attr("ows_RecurrenceData");

                        events.push({
                            //          className: ownerClass, \\Will be an @attrib in the responseXML
                            title: thisTitle,
                            start: $(this).attr("ows_EventDate"),
                            end: $(this).attr("ows_EndDate"),
                            allDay: thisADE,
                            url: thisUrl,
                            description: thisDesc
                        });

                    });
                }
            });
        });


enter image description here

  • Is the path to jquery file correct ? Looks like you are having problem loading jquery file. – Gautam Sheth Oct 4 '16 at 6:01
  • yes the path is correct because this path related issue arises only when am running this code – Madhav Oct 4 '16 at 6:13
3

Here is an example of accessing the all Recurrence Event from calendar List using the JavaScript:

<script type="text/javascript">
    $(document).ready(function () {
    debugger;
    $(".readItem").click(function(){
    var html="";
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "/sites/demo/Style%20Library/cascade/jquery.SPServices-2014.02.min.js"; 
    document.getElementsByTagName("head")[0].appendChild(script);
    var start = new Date();debugger;
    $().SPServices({
                    operation: "GetListItems",
                    async: false,
                    listName: "Calendar",
                    CAMLViewFields: "<ViewFields>" +
                              "<FieldRef Name='Title' />" +
                              "<FieldRef Name='EventDate' />" +
                              "<FieldRef Name='EndDate' />" +
                              "<FieldRef Name='Location' />" +
                              "<FieldRef Name='Description' />" +
                              "<FieldRef Name='fRecurrence' />" +
                              "<FieldRef Name='RecurrenceData' />" +
                              "<FieldRef Name='fAllDayEvent' />" +
                          "</ViewFields>",
                    CAMLQuery: '<Query>' +
                          '<CalendarDate>' + start + '</CalendarDate>' +
                          '<Where>' +
                              '<DateRangesOverlap>' +
                              '<FieldRef Name="EventDate" />' +
                              '<FieldRef Name="EndDate" />' +
                              '<FieldRef Name="RecurrenceID" />' +
                              '<Value Type="DateTime">' +
                                  '<Year />' +
                              '</Value>' +
                              '</DateRangesOverlap>' +
                          '</Where>' + '<OrderBy>' +
                              '<FieldRef Name="EventDate" />' +
                          '</OrderBy>' +
                          '</Query>',
                    CAMLQueryOptions: '<QueryOptions>' +
                              '<CalendarDate>' + start + '</CalendarDate>' +
                              '<RecurrencePatternXMLVersion>v3</RecurrencePatternXMLVersion>' +
                              '<ExpandRecurrence>TRUE</ExpandRecurrence>' +
                          '</QueryOptions>',
                    completefunc: function (xData, Status) {
                        var events = [];

                     alert(Number($(xData.responseXML).find("rs\\:data, data").attr("ItemCount")));
                        $(xData.responseXML).SPFilterNode("z:row").each(function () {
                            var fADE = $(this).attr("ows_fAllDayEvent");
                            if (fADE != null) {
                                if (fADE == 0) { thisADE = false }
                                else thisADE = true;
                            }
                            var thisID = $(this).attr("ows_ID");

                            var thisTitle = $(this).attr("ows_Title");
                            var thisRecurrence = $(this).attr("ows_fRecurrence");
                            var thisDesc = $(this).attr("ows_Description");


                            var thisUrl = "DispForm.aspx?ID=" + thisID + "&Source=FullCalendar.aspx";
                            var thisRD = $(this).attr("ows_RecurrenceData");
    alert("Title:"+thisTitle+"\n"+"Start Date:"+$(this).attr("ows_EventDate")+"\n"+"EndDate:"+$(this).attr("ows_EndDate"));
    html+="<p>"+thisTitle+"</p><p>"+$(this).attr("ows_EventDate")+"</p><p>"+$(this).attr("ows_EndDate")+"</p>";


                        });
                        $(".items").html(html);

                    }

                });
                });
                });

    </script>​​​

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.