CalenStyle icon indicating copy to clipboard operation
CalenStyle copied to clipboard

Example for a URL data events

Open elecoest opened this issue 7 years ago • 4 comments

Hello,

Is it possible to have a example for URL events ?

In my test, i have a URL which return

{
"identifier": "1", 
"isAllDay": false, 
"start": "22-05-2016 09:00",
"end": "22-05-2016 10:00",
"calendar": "Meeting", 
"tag": "Work",
"title": "Meeting with Ana", 
"description": "", 
"url": "", 
"icon": "cs-icon-Meeting", 
"color": "20DAEC", 
"borderColor": "000000", 
"textColor": "000000",
"nonAllDayEventsTextColor": "000000",
"isDragNDropInMonthView": true, 
"isDragNDropInDetailView": true, 
"isResizeInDetailView": true 
}

It's OK but I have an erreur with a fictive URL :

none:1 GET http://127.0.0.1/fdg/none 404 (Not Found)

Thanks

elecoest avatar Jun 29 '17 12:06 elecoest

in fact, the code

 $.getJSON(sBaseUrl, oUrlParam)
                .done(function (sJsonStr) {
                    to.tv.iLoadCnt--;

                    sJsonStr = to.__parseJson(sJsonStr);
                    console.log("Json Response : ");
                    console.log(sJsonStr);
                    to._parseAllDataSources(sJsonStr, oConfig, bGoogleCalendar, dTempDurationStartDate, dTempDurationEndDate, loadViewCallback);
                })
                .fail(function (oJqXHR, sTextStatus, oError) {
                    to._stopDataLoading(dTempDurationStartDate, dTempDurationEndDate, loadViewCallback);
                    console.log("Request Failed : " + sTextStatus + "  :  " + oError);
                });
       },

interpret sJsonStr as an object and not like a string...

elecoest avatar Jun 29 '17 15:06 elecoest

code which OK :

			calDataSource: 
					[					
					    {
                            sourceFetchType: "DATERANGE",
                            sourceType: "FUNCTION",						
                            source: function(fetchStartDate, fetchEndDate, durationStartDate, durationEndDate, oConfig, loadViewCallback)
                            {
                                var calObj1 = this;
                                calObj1.incrementDataLoadingCount(1);
                    
					            $.ajax({
                                    type: "GET",
                                    contentType: "application/json",
                                    data: {
                                        "fetchStartDate": fetchStartDate,
									    "fetchEndDate": fetchEndDate									
                                    },
                                    url: "index.php?option=com_ajax&module=aecalen&format=raw",
                                    dataType: "json",
                                    async: false,
                                    success: function (data) {
                                        oEventResponse = data ; 
                                    }
                                });
					
					            if(oEventResponse != undefined)
                                {
                                    calObj1.parseDataSource("eventSource", oEventResponse, durationStartDate, durationEndDate, loadViewCallback, oConfig, false);
                                }
                            }
                        }
					],

elecoest avatar Jun 30 '17 08:06 elecoest

Hello @elecoest,

$.getJSON( baseurl, urlparams )
.done(function(json)
{
})
.fail(function(jqXHR, status, error)
{
});

is equivalent to

$.ajax({
  dataType: "json",
  url: url,
  data: data,
  success: success
});

If response is returned with status code 404, fail callback is executed. I have tested by sending status code 404 with text "Not Found". It worked.

parsererror occurs when text is sent with status code 200. I will add a condition to check whether returned value is string. But Calendar is rendered, view is not affected.

Please share details of HTTP status code and response body and console error because rather than workaround I can improve plugin.

nehakadam avatar Jun 30 '17 17:06 nehakadam

Response is OK :)

The error provide for the type of response. In my case it's an object JSON not a stringify... So for me and with a page wich return a simple array of json it's not OK by URL.

Like as say it's OK with an inclusion of my ajax call in a function...

2017-06-30 19:05 GMT+02:00 Neha Kadam [email protected]:

Hello @elecoest https://github.com/elecoest,

$.getJSON( baseurl, urlparams ) .done(function(json) { }) .fail(function(jqXHR, status, error) { });

is equivalent to

$.ajax({ dataType: "json", url: url, data: data, success: success });

If response is returned with status code 404, fail callback is executed. I have tested by sending status code 404 with text "Not Found". It worked.

parsererror occurs when text is sent with status code 200. I will add a condition to check whether returned value is string. But Calendar is rendered, view is not affected.

Please share details of HTTP status code and response body and console error because rather than workaround I can improve plugin.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nehakadam/CalenStyle/issues/11#issuecomment-312321630, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGe-oEQ1L1pL60ixHaiMtmn_k4SkhHFks5sJSrEgaJpZM4OJQXU .

elecoest avatar Jun 30 '17 17:06 elecoest