Skip to content Skip to sidebar Skip to footer

How To Extract DataTable From DataSet Which Is In JSON Format

I am using Newtonsoft dll for serialization. I am currently returning DataTable from webmethod in Json Format. And it works fine. But I want to do the same thing by returning Data

Solution 1:

Finally, I succeeded.

Inside Ajax Success, do like below...

var dataSet = jQuery.parseJSON(data.d);
var dataTable = dataSet["patients"];

$.each(dataTable, function () {
    myDropDownList.append($("<option></option>").val(this['id']).html(this['name']));
});

Solution 2:

var aa={"patients":[{"name":"sam","id":"1"},{"name":"mark","id":"2"}],"medications":[{"id":"1","medication":"atenolol"},{"id":"2","medication":"amoxicillin"}]}
console.log(aa["patients"]);
console.log(aa["medications"]);

This is just a example

You can see that when you have two level json object you have to use it with the name

and your object will be like the datatable

Please check the demo here Demo


Post a Comment for "How To Extract DataTable From DataSet Which Is In JSON Format"