Help parsing JSON API URL into table for data
Help parsing JSON API URL into table for data
thatgreg
Posts: 6Questions: 4Answers: 0
(link to my code)
https://jsfiddle.net/thatgreg/khyjo6u3/10/
Right now I have to manually input the data I see from the JSON URL.
I'm trying to create a dynamic table so is there a way that the data loads to the table from the URL?
thank you and please help.
Answers
Use Ajax.
https://datatables.net/examples/data_sources/ajax.html
Replace '../ajax/data/arrays.txt' with the url you're getting your data from.
Hi, sorry forgot to include the api link.
https://api.fda.gov/device/510k.json?search=product_code:NBW&limit=100
Will this still work with "ajax" ??? thank you
That helps
See this example with your URL:
http://live.datatables.net/dukenazi/1/edit
It uses
ajax.dataSrc
to point to theresults
property. Originally the request was appending_={timestamp}
to the URL causing an error with the API. One option to fix is to addcache: true,
. See the jQuery Ajax docs for more details.The
columns.data
is used to define the properties you want to show. See the Datatables ajax and data docs for more details.The data has the
openfda
property which has properties underneath. This nested objects example shows how to access the nested data.Kevin