Link to home
Start Free TrialLog in
Avatar of Shaji

asked on

How to retrieve specific JSON records from a AJAX call

I am calling a REST based URL


and it returns the following data (only 2 records are shown for simplicity)


Open in new window

I am constructing a data table from the records. How to pass specifically the records in the place of the URL. As I understand it is expecting the URL instead of JSON data at line number 12

$(document).ready(function() {
var baseURL = "http://localhost:8080/idt-ws/ver1.0";
var path = "/resources";
var requestURL = baseURL + path;

$.getJSON(requestURL, function(data) {
var table = $('#idt-table').DataTable( {
	"scrollY": "300px",
        "scrollCollapse": true,
        "ajax": {
            "url": data.records,
            "dataSrc": ""
        "columns": [
            { "data": "hostname" },
            { "data": "dbname" },
            { "data": "resname" },
            { "data": "resid" }
    } );

Open in new window

I created a separate JSON file viz. 'data.json' and replaced it in line number 12, as shown above and it worked, but giving the array 'data.records' in the URL is not working.

Please help
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

I think what you are looking is a way to filter JSON result.

You can look at the blog post @, which explains how to use datafilter with jQuery Ajax calls.
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shaji


Thanks Rainer, it is working  like a champ