How to parse JSON data in jQuery Datatable

This Datatable jquery tutorial help to parse JSON data which was received from server side.I got huge response from reader on datatable tutorials,i am sharing next level datatable tutorial with php and mysql,I am extending Datatable Pagination, Sorting and Search – Server Side (PHP/MySQl) Using Ajax.

Sometimes we need to add some text,process json data or filter JSON object data before to send datatable jQuery table.I am using Datatable in-build call back dataSrc() function which will parse JSON data as your requirement and send to datatable.

parse-json-data-jquery-datatable

This tutorial will help to achieve following milestone,

  • Added Hyperlink(Anchor HTML tag) on column in jquery datatable.
  • Added img HTML tag in table td column.
  • Added edit/delete and view action button.

Also Checkout other tutorial of jQuery Datatable,

I am are using below Files in this tutorial

Index.php - This file will responsible to create html and instance datatable using jquery code.
response.php - This file responsible to create database connection string and convert records into json string and returns data to Ajax method as response.
connection.php - This file responsible to create mysql database connection.

I already mentioned in this post i am extending Datatable Pagination, Sorting and Search – Server Side (PHP/MySQl) Using Ajax, so i assumed you have read and understand that tutorial.

How to parse JSON data in jQuery Datatable

Step 1: we will create new profile_image column in employee table. This column will store profile image path.

Step 2: Added profile_image column in $column array in response.php file.

Step 3: Added profile_image and Action column in HTML table header and footer heading in index.php file.

Step 4: We will user dataSrc callback jquery datatable function to parse JSON object.This function will take JSON data as a parameter which will returned from Ajax request.

as you can see above code, I am adding following functionality,

  1. Adding img html tag with profile_image column value
  2. Adding href attribute on each name column value
  3. Adding new column Action column which will take edit/delete and view anchor tag

Conclusion

We have learn how to parse received server JSON object in client side and send to jQuery datatable.This jQuery tutorial help to add or modified JSON object before render datatable in HTML table format.We have added Image and anchor HTML tag with column value in td.

You can download source code and Demo from below link.