How to sort datatable by making multiple requests?

How to sort datatable by making multiple requests?

vivek14089vivek14089 Posts: 1Questions: 1Answers: 0

Hi all

Below is my script . I am getting multiple JSON responses from differernts server in a loop in jquery and each time I am adding the result in data taable but while sorting I am able to see only the first response sorted in a datatble. I want to auto sort the complete table after appending all the responses in a datatable. Is there any way to do so?

Right now, i have to refresh the page once otr twice or multiple times to see all the responses sorted together.

Below is my script where in a loop m getting multile JSOn responses. Please help :)

$(document).ready(function(){ alert('Hello'); var url=""; var port="33500"; $.getJSON('http://msplwa107:33500/rest/MdtAny_MondayMonitor/services/consumer/_get HTTP/1.1',function(data){ $.each(data.allServers, function(i,a) { url="http://"+a+":"+port+"/rest/MdtAny_MondayMonitor/services/Consumer_schedulers/_get HTTP/1.1"; //url="http://localhost:5555/rest/MdtAny_MondayMonitor/services/Consumer_adapters/_get HTTP/1.1"; $.getJSON(url, function(data) { //console.log(data); var row = $("") $("#person").append(row); $.each(data.final_schedulers, function(i,a) { if(a.status=="NOT_OK") { var row = $("") $("#person").append(row); //this will append tr element to table... keep its reference for a while since we will add cels into it row.append($("" +""+ a.name + "")); row.append($("" + a.exec_state + "")); row.append($("" + a.status + "")); row.append($("" + a.server + "")); } else{ var row = $("") $("#person").append(row); //this will append tr element to table... keep its reference for a while since we will add cels into it row.append($("" + a.name + "")); row.append($("" + a.exec_state + "")); row.append($("" + a.status + "")); row.append($("" + a.server + "")); } }); $("#person").dataTable().fnDestroy(); $(document).ready(function() { $('#person').DataTable( { "order": [[ 0, "asc" ]], bRetrieve: true } ); }); }); }); }) });

Answers

This discussion has been closed.