How to load data source using api query?
How to load data source using api query?
balaram26
Posts: 2Questions: 1Answers: 0
I access data through certain API's. HOw to use the data table server side scripting for this purpose? I have tested both the options of trying to provide ajaxurl as API query address directly or use a PHP to get the data from API query and then provide php as the ajaxurl. Both the API and php return JSON data type,yet they fail. Are there any complete working examples to show this?
This discussion has been closed.
Answers
Your methods should work if coded correctly. What do you mean by "they fail"?
What DataTables sends to the server and what it expects back are documented here. If your APIs on the server-side handle that information and return the expected JSON, it should just work.
Allan
Hi ,here is what my code looks like-
my json looks like-
The above js is added to the HTML page and the the api aldready provides with the above described JSON as the result for the given API query. Should anything has to be changed for the tables to be loaded ?? The **"ajax": "http://xxxxx" ** contains the API query which is present from the server side [i was told that its handled java program].
The JSON being returned from the server does not contain the information that DataTables requires for server-side processing. You need to include the paging and search information in the returned JSON as documented.
Allan