$("#table-list tr").detach();
$.get(url+"payroll/payroll-ajax.php","id="+arg+"¶m=view_loan",function(data){
var objJSON = eval("(function(){return " + data + ";})()");
var i=objJSON.length;
for (var j=0;j<i;j++) {
k=j+1;
var newRow =
"<tr>"
+"<td>"+k+"</td>"
+"<td>"+objJSON[j].deduction_date+"</td>"
+"<td>र "+objJSON[j].deduction_amt+"</td>"
+"</tr>" ;
$(newRow).appendTo("#table-list tbody");
}
$('#view-loan-table-modal').modal('toggle');
var objJSON="";
});
This above code is used to get multiple rows from json object.
If the variable data is contains following values.
data=[{"id":"3","loan_id":"8","deduction_date":"2014-07-16 12:54:14","deduction_amt":"16667"},{"id":"9","loan_id":"8","deduction_date":"2014-08-12 10:25:36","deduction_amt":"16667"},{"id":"10","loan_id":"8","deduction_date":"2014-08-12 02:22:53","deduction_amt":"16667"}]
This is JSON object value.
The out put is:
$.get(url+"payroll/payroll-ajax.php","id="+arg+"¶m=view_loan",function(data){
var objJSON = eval("(function(){return " + data + ";})()");
var i=objJSON.length;
for (var j=0;j<i;j++) {
k=j+1;
var newRow =
"<tr>"
+"<td>"+k+"</td>"
+"<td>"+objJSON[j].deduction_date+"</td>"
+"<td>र "+objJSON[j].deduction_amt+"</td>"
+"</tr>" ;
$(newRow).appendTo("#table-list tbody");
}
$('#view-loan-table-modal').modal('toggle');
var objJSON="";
});
This above code is used to get multiple rows from json object.
If the variable data is contains following values.
data=[{"id":"3","loan_id":"8","deduction_date":"2014-07-16 12:54:14","deduction_amt":"16667"},{"id":"9","loan_id":"8","deduction_date":"2014-08-12 10:25:36","deduction_amt":"16667"},{"id":"10","loan_id":"8","deduction_date":"2014-08-12 02:22:53","deduction_amt":"16667"}]
This is JSON object value.
The out put is: