How to execute an ajax call on a url
How to execute an ajax call on a url
islamelshobokshy
Posts: 99Questions: 20Answers: 1
I'm trying to execute an ajax call on a URL https://site.com/api/X/Y
and not on a json file, the api does return a json formated file. How can I do so using the datatables ajax method?
ajax: {
url: "<?php echo $url?>",
type: "GET"
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
What are you using for your server code?
Its up to the server code to encode the data result into a JSON string before returning the result.
Kevin
@kthorngren I'm just trying to get the json of an API. As if I would use :
Sorry, I misread your original description. What is returned when you use the
ajax
option?Datatables basically passes your ajax config to the jQuery ajax method. However Datatables has it's own option called
ajax.dataSrc
used to extract data if not in the expecteddata
object. Maybe you need to useajax.dataSrc
to tell Datatables where the data is.Kevin
It was indeed ajax.dataSrc, thanks !