Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for a URL data events #11

Open
elecoest opened this issue Jun 29, 2017 · 4 comments
Open

Example for a URL data events #11

elecoest opened this issue Jun 29, 2017 · 4 comments

Comments

@elecoest
Copy link

elecoest commented Jun 29, 2017

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
Copy link
Author

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
Copy link
Author

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);
                                }
                            }
                        }
					],

@nehakadam
Copy link
Owner

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.

@elecoest
Copy link
Author

elecoest commented Jun 30, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants