Loading multiple JSON files.

Loading multiple JSON files.

damaya1982damaya1982 Posts: 12Questions: 0Answers: 0
edited August 2013 in General
I have a folder on my web server with multiple JSON files that I would like to load into my Datatable. The files are all in the same format. I am currently doing this:

"bProcessing": true,
"sAjaxSource": "servers/test.json",

And it works. What I'd like to do is something like: "sAjaxSource": "servers/*", so that it loads all the files. Is this possible?

Replies

  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    Are these json files all the same data structure? i.e, they're all the same columns, etc? If that's the case, I would write a small php script to aggregate them all together and output 'master.json'. I don't see what you need as being very useful to most use cases...
  • damaya1982damaya1982 Posts: 12Questions: 0Answers: 0
    They are all the same data structure. However, I am doing this entirely without PHP, CGI, etc. So, that's not really an option for me.
  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    > "servers/*", so that it loads all the files. Is this possible?

    Its not possible since the Javascript doesn't have access to your server's file system (I'm shivering just at the thought of that - omg!).

    As aaronw says, you would need to tell the client-side what files are on the server (if you've got bash that would do. What system are you running it on a Linux / Busybox one?). The other option is to just hard code the file names and use your own Ajax to load them one by one (which you would need to do even if you had the file names).

    Allan
  • damaya1982damaya1982 Posts: 12Questions: 0Answers: 0
    Thanks for the response Allan, and major props on an awesome plugin. I was actually able to figure this out, but I ended up having to do server-side processing using a Perl script. No biggie, was just wondering if the functionality of it was possible.
This discussion has been closed.