allow CORS on server side examples

allow CORS on server side examples

ctaggartctaggart Posts: 2Questions: 0Answers: 0
edited January 2013 in Feature requests
When playing around with the server side examples locally, it would be very convenient if the service side data service examples support CORS.
It looks like it may simply be a one line change to enable. <?php header("Access-Control-Allow-Origin: *");
http://enable-cors.org/server_php.html.

With it enabled, this should work from a local file:

$.ajax({
type: 'GET',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
url: 'http://www.datatables.net/release-datatables/examples/server_side/scripts/server_processing.php'
});

In the meanwhile, it is possible to load Chrome with same origin policy disabled, but is not a great workaround.

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Some of the examples have JSONP support which you could use: http://datatables.net/release-datatables/examples/server_side/jsonp.html

    I'm not overly keen on opening more resources on this little server - its already getting a hammering! :-). Indeed I was actually thinking of ways to reduce the server being (incorrectly) used as a CDN by many. But certainly something I'll keep in mind for future as I can see it would be useful for testing.

    Allan
  • ctaggartctaggart Posts: 2Questions: 0Answers: 0
    May be just allowing an Origin of null for local files would work. I just posted a blog about using DataTables from TypeScript and added some details to this issue.
    http://blog.ctaggart.com/2013/01/trying-out-typescript.html
This discussion has been closed.