I am using below code to get data from a list later binding to a table but while implementing paging, I am facing some issues.
function GetData(arrayID)
{
$.each(arrayID, function( index, value ) {
if(arrayID[index]!=null)
{
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('test')/items?$select=Array_ID,Title,LAST_NAME,EMPLOYEE_CODE,DESIGNATION,LOCATION&$filter=Array_ID eq '"+arrayID[index]+"'";
$.ajax({
url: url,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
complete:function(data){
},
success: function(data) {
var arrayID = data.d.results[0].ORACLE_HR_ID;
var employeeName = data.d.results[0].Title + " " + data.d.results[0].LAST_NAME;
ShowData(ohrID,employeeName);
},
error: function(data) {
console.log("error");
}
});
}
});
$('#tblCustomListData').dataTable({
paging: true,
searching: true,
bDestroy: true,
"iDisplayLength": 5 ,
"lengthMenu": [5,10, 25, 50, 100]
});
});
}
This is not working perfectly as the code of paging needs to be executed after the completion of .each function. So can I make the paging code to be executed at the end of this .each function?