This is a migrated thread and some comments may be shown as answers.

Handling JSONP errors

1 Answer 63 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 09 Aug 2013, 04:57 PM
Does the DS have any way for me to capture and handle jsonp errors?

Is there a best practice?

I've tried this, but nothing happens (no alerts)

dataSource: new kendo.data.DataSource({
                    serverFiltering: true,
                    transport: {
                        read: {
                            url: function (e) {
                                var value = $("#activityTypeBox").data("kendoDropDownList").value();
 
                                if (value != "") {
                                    return "http://site/api/activities/getByType/id/" + value + "/format/jsonp"
                                }
                            },
                            dataType: "jsonp",
                            jsonpCallback: 'myCallback'
                        },
                        parameterMap: function (data, type) {
 
                        }
                    },
                    schema: {
                        errors: "error" // ex: twitter's response is { "error": "Invalid query" }
                    },
                    error: function (e) {
                        alert("Problem populating the curriculum db activities based on that type");
                    }
                })

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Aug 2013, 09:07 AM
Hi Steve,

 The error event of the data source relies on the error callback of jQuery.ajax. For some reason that callback is not invoked when using JSONP and the url is wrong. Here is a quick demo showing that: http://jsbin.com/ecofic/1/edit. This seems to be a known limitation.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Atanas Korchev
Telerik team
Share this question
or