Retrieving data from DB without a table
Retrieving data from DB without a table

Hello
I'm developing a system of which DataTables is essentially the core functionality. In order to avoid convolution the programming side of it, I'm planning to use the DataTables PHP lib to retrieve data from the DB. Is there a way I can leverage the existing AJAX system to pull data into a function? Or will I need to write my own utility to do that?
Thanks in advance,
David
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I don't quite understand what you mean by pulling the "data into a function"? If you've got a DataTable with data in it on the client-side and you want to access that data, you can use
rows().data()
.Allan
Morning @allen ,
I wanted to use the DataTables PHP interface to get information from the database, but without using a table in the process. This was the solution that I whipped up:
I was just wondering if there was anyway to use the DataTables AJAX rather than mine, since mine has no error callback.
Cheers,
David
Yes, I believe you should be able to use DataTables for that. Could you show me a sample of what
DataTablesSource/php/table.home.personal.php
returns first though before I give you misinformation!Allan
Hey @allan ,
It reads:
and when directing straight to it in the browser returns:
Many thanks,
David
Ah! I see - sorry. I hadn't realise that you were actually using Editor's server-side libraries. I thought you weren't sure on how to use DataTables'
ajax
option to load object data, but that's not the issue here - you want to use the Editor server-side libraries to load information for the details row~Since we've got jQuery on the page, rather than having your own XHR you could simplify your code with:
Allan
Ah brilliant, thanks for the pointer!
The only change I made was
JSON.parse(json)
in theformat_data(json)
call:Many thanks,
David