The json output that I have is below
[{"param1":"value1","param2":"value2","param3":"value3"},{"param1":"value1","param2":"value2","param3":"value3"}]
My ajax request is coded in a function so that it can called based on button click:
function callAjaxRequest()
{
ajaxRequest = $.get('getdata',{ 'parameter1': paramValue1,'parameter2':paramValue2 },function(responseinjson) {
if(responseinjson!=null){
$("#table1").find("tr:gt(0)").remove();
var tablevar = $("#table1");
$.each(responseinjson, function(key,value) {
var rowNew = $("<tr><td><td></td></tr>");
rowNew.children().eq(0).text(value['param1']);
rowNew.children().eq(1).text(value['param2']);
rowNew.appendTo(tablevar);
});
var numberofrecords = responseinjson.length;
}
}
}
I initialized ajax request to variable because I can abort it later in some cases.
Now my problem is I can see lot of delay in the for each loop based on the huge number of records. So, can someone please suggest me how to implement pagination according to the responseinjson
value using datatable in jquery. I have seen lot of examples on the internet but I can't get my head around it on how to use according to the response that I get. Please go easy on my question if it sounds noob as I am new to web development.
P.S: I don't want to add to datatable using for each loop because it results in same delay that I am getting now.
Reiterating my point for bounty: I am getting entire json response in the ajax call as per my code snippet. But I found that it is taking considerable delay to show up the data, so the for each jquery loop to show data is taking too much time. So, is there anyway that I can paginate this without lopping through the entire json response.