Datatable not integrated in ajax response.
Datatable not integrated in ajax response.
sushilsth
Posts: 1Questions: 1Answers: 0
Hi, I had to make the datatable from the ajax response. I made it and result is sucessfull but i cannot integrate it in datatable. I had linked js and css file and initialized it also but not working. How can i make it work .Below are my code. Am i doing anything wrong.
$("#tbl_product_refined").DataTable();
//search seller type
$("#individual").live("click",function(){
var tbl="";
$.ajax({
type: "POST",
url: "<?php echo base_url().'index.php/cms/filter_seller_type'; ?>",
dataType: "json",
data: {
},
success: function(msg)
{
var len = msg.length;
//alert(len);
var ftbl = '<table class="table table-striped table-bordered" id="tbl_product_refined">' +
'<thead><tr style="color:#fff;background:#49bf67;"><th>Seller Information</th><th>Product Information</th>' +
'<th>Posted Date</th><th>Post Status</th>' +
'</tr></thead><tbody>';
for (i = 0; i < len; i++)
{
tbl += '<tr><td><span style="border-bottom:1px dotted;"><b>Name:</b>' +
msg[i].seller_name + '</span><br><span style="border-bottom:1px dotted;"><b>E-mail:</b>' +
msg[i].seller_email + '</span><br><span style="border-bottom:1px dotted;"><b>Mobile:</b>' +
msg[i].seller_mobile + '</span><br><span style="border-bottom:1px dotted;"><b>Type:</b>' +
msg[i].seller_type + '</span><br><span style="border-bottom:1px dotted;"><b>City:</b>' +
msg[i].city + '</span><br><span style="border-bottom:1px dotted;"><b>Locality:</b>' +
msg[i].locality + '</span></td><td><span style="border-bottom:1px dotted;"><b>Name:</b>' +
msg[i].model_category + '</span><br><span style="border-bottom:1px dotted;"><b>Title:</b>' +
msg[i].titles + '</span><br><span style="border-bottom:1px dotted;"><b>Description:</b>' +
msg[i].description + '</span><br><span style="border-bottom:1px dotted;"><b>Condition:</b>' +
msg[i].conditions + '</span><br><span style="border-bottom:1px dotted;"><b>Price:</b>' +
msg[i].price + '</span><br><span style="border-bottom:1px dotted;"></span></td><td>' +
msg[i].post_date_time + '</td></tr>';
}
var ltbl = '</tbody></table>';
$("#start_tbl").html(ftbl + tbl + ltbl);
}
});
});
This discussion has been closed.