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

Getting data from a web service - error "Access-Control-Allow-Origin" header

1 Answer 288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 04 Feb 2016, 11:04 PM

Just trying out this framework. I am developing in Xpages (basically JSP). I have a rest service that I can call from the browser and get JSON data. 

I am consuming data from this rest service in other applications.

I got a grid to work in a page using Kendo, with local data and data from the kendo service.

When I try to hook it up to my rest service I get the error ==

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxx' is therefore not allowed access.

 I believe this is a cross domain security feature, however, the service is from the same domain.

 

My code looks like this:

 

 $(document).ready(function () {
            $("#grid").kendoGrid({
                dataSource: {
                         type: "json",
                    transport: {
                        read: "http://xxxxxxxxx"
                    },
                    pageSize: 20
                },
                height: 550,
                groupable: true,
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: true,
                    buttonCount: 5
                },

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 08 Feb 2016, 01:57 PM
Hi Bryan,

A cross-origin error will occur if the domain name, port or protocol of the data service URL do not match the ones of the web page. There is surely some discrepancy in your case - for example, you may be opening the web page via the file system (i.e. using the file:// protocol).

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Bryan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or