CodeIgniter 3 DataTables Ajax Server-side Processing

CodeIgniter 3 DataTables Ajax Server-side Processing

In this Post We Will Explain About is CodeIgniter 3 DataTables Ajax Server-side Processing With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to DataTables Server-side Processing using CodeIgniter 3 with MySQL Example

In this post we will show you Best way to implement Codeigniter 3 Datatables Ajax Example From Scratch, hear for Datatables:Client and server-side processing(Codeigniter 3,MySQL,Ajax) with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Phase 1: Create products table

In this phase we will make new new table Like as “products” in database. You can phase by phase use simple SQL Query for make “products” table. Therefor here simple copy and paste this script make using bellow sql table query:

Also Read :   Add and Delete rows Dynamically using jQuery

products table:

  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `item_info` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)

Phase 2: Create Codeigniter 3 Routes

And then, we will Put new routes data for list of products. Therefor first open routes.php file after that Replace this scripts like as bellow source code:


defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE; // Boolean true or false
$route['product'] = "product/index";
$route['retrive_products'] = "product/retrive_products";

Phase 3: Create Product Controller

And then, we have to make “Product” controller with simple ci index() and retrive_products(). Therefor create ImageUpload.php file in this path like as a application/controllers/Product.php and put bellow code in this file:

Also Read :   Creating RESTful API with Slim Framework,PHP/MySQl


defined('BASEPATH') OR exit('No direct script access allowed');
class Product extends CI_Controller {

   public function __construct() {

   public function index()

   public function retrive_products()
      $cidraw = intval($this->input->get("draw"));
      $start = intval($this->input->get("start"));
      $length = intval($this->input->get("length"));

      $livequery = $this->db->get("products");
      $alldata = [];
      foreach($livequery->result() as $r) {
           $alldata[] = array(

      $lstresult = array(
               "draw" => $cidraw,
                 "recordsTotal" => $livequery->num_rows(),
                 "recordsFiltered" => $livequery->num_rows(),
                 "data" => $alldata

      echo json_encode($lstresult);

Phase 4: Make View File

In this phase we will make our simple index.php HTML view file . In this simple main file we will Learning design of html Advance table and some CDN include datatables. So first of all update following CDN file as well as scripts:

Also Read :   AngularJS Upload Image Using PHP


<!DOCTYPE html>
	<title>Simple Codeigniter 3 Datatables Ajax Example</title>
	<link rel="stylesheet" href="3.3.7/css/bootstrap.min.css" />
	<script src="3.2.1/jquery.js"></script>
	<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
	<script type="text/javascript" src="datatables.min.js"></script>
	<script type="text/javascript" src="dataTables.bootstrap.min.js"></script>
<div class="live24u container">
	<h2>Simpl Codeigniter 3 Datatables Ajax Step By Step Example</h2>
	<table id="products-list" class="table table-bordered table-striped table-hover">
				<th>Product ID</th>
				<th>Product Title</th>
				<th>Prod. Information</th>
<script type="text/javascript">
$(document).ready(function() {
        "ajax": {
            url : "/retrive_products",
            type : 'GET'

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example


I hope you have Got What is Using Datatables with CodeIgniter 3 Tutorial And how it works.I would Like to have FeedBack From My Blog( readers.Your Valuable FeedBack,Any Question,or any Comments about This Article( Are Most Always Welcome.