sAjaxSource set to a static file on Amazon S3

sAjaxSource set to a static file on Amazon S3

yasvintusyasvintus Posts: 7Questions: 0Answers: 0
edited December 2012 in General
Hello,

Hopefully this is a quick one. I am using a static json file for my data source:

[code]
$(window).load(function() {
$('#table-results').dataTable({
"sAjaxSource": "data.json",
});
});
[/code]

... and everything works great.

Now, ideally I'd like to load the json file from an Amazon S3 bucket, like so:
[code]
$(window).load(function() {
$('#table-results').dataTable({
"sAjaxSource": "https://s3.amazonaws.com/mybucketname/data.json",
});
});
[/code]

... but this is not working. From the reading I did on this forum, the issue probably relates to the XSS (cross-site scripting) safeguards. So here is my question: is my assessment of the issue correct and if yes what workarounds if any I can employ to get this setup to work?

Thanks in advance for your help!

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    There are several options which you'll find if you Google for them:

    1. Use JSONP (might not be an option if the file has to be static)
    2. Use Yahoo Pipes
    3. Use a proxy script
    4. Use Flash
    5. More? Probably - Google them :-)

    Allan
  • yasvintusyasvintus Posts: 7Questions: 0Answers: 0
    Hi Allan,

    Thanks for pointing me in the right direction. I must have not googled the right terms. I only came across option 1 in your list, but ruled it out because I assumed it requires the json to be served up by a process, rather than from a file. My entire website is static content, and I need to keep it this way, so I am guessing options 3 and 4 are out as well. I'll research Yahoo Pipes a little bit more.

    But in any case -- thank you so much for your reply!

    Daniel
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Have a look at http://www.datatables.org/ (not related to this DataTables btw - just coincidental naming :-) ). I've used that for cross domain scripting before.

    Allan
This discussion has been closed.