{"id":2755,"date":"2017-04-29T08:38:03","date_gmt":"2017-04-29T08:38:03","guid":{"rendered":"http:\/\/www.mobisoftinfotech.com\/blog\/?p=2755"},"modified":"2024-08-21T17:05:34","modified_gmt":"2024-08-21T11:35:34","slug":"jquery-datatable-ajax-tutorial-with-example-project","status":"publish","type":"post","link":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project","title":{"rendered":"jQuery Datatable Ajax Tutorial With Example Project"},"content":{"rendered":"<h3><strong>Introduction<\/strong><\/h3>\n<p>Hi,<br>\nThe goal of this blog is to show how you can implement fully functional, high-performance tables using the <a title=\"Datatable Plug-ins\" href=\"http:\/\/datatables.net\/plug-ins\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\" data-abc=\"true\">jQuery DataTables plug-in<\/a>.<\/p>\n<p>Basically, There are many ways to get your data into DataTables, and if you are working with large databases, you might want to consider using the server-side options that DataTables provides. Basically all of the filtering, paging, sorting, changing page length, etc. and DataTables is just an event and display module. The preferred two ways for <a title=\"Jquery Datatable\" href=\"http:\/\/datatables.net\/extras\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\" data-abc=\"true\">JQuery Datatable<\/a> processing are <strong>Client-side processing<\/strong> and <strong>Server-side processing<\/strong>. This is a JavaScript plug-in implemented using the jQuery library that handles all the necessary interaction with the user on the client-side. So, Here I came up with a blog for jQuery Datatable as I really liked this control. This article shows how the <a title=\"Datatable Plug-ins\" href=\"http:\/\/datatables.net\/plug-ins\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\" data-abc=\"true\">jQuery DataTables plug-in<\/a> can be integrated into Java web applications.<\/p>\n<p>This sample shows how you can generate a table of students and add the <a title=\"Datatable Plug-ins\" href=\"http:\/\/datatables.net\/plug-ins\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\" data-abc=\"true\">jQuery DataTables plug-in<\/a> to the HTML table. In that case, Everything is implemented using JavaScript functionalities so you do not need to do anything else. The only thing you need to do is generate a plain table as in the initial case. The new, enhanced table is shown in the following figure:<\/p>\n<p><noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-16152\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\" alt=\"Documents\" width=\"670\" height=\"274\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png 670w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy-300x123.png 300w\" sizes=\"(max-width: 670px) 100vw, 670px\"><\/noscript><img decoding=\"async\" class=\"alignnone size-full wp-image-16152 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20670%20274%22%3E%3C%2Fsvg%3E\" alt=\"Documents\" width=\"670\" height=\"274\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20670%20274%22%3E%3C%2Fsvg%3E 670w\" sizes=\"(max-width: 670px) 100vw, 670px\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png 670w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy-300x123.png 300w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\"><\/p>\n<h3><strong>Using the code<\/strong><\/h3>\n<p>This sample shows how you can generate a table of Students and add the jQuery DataTables plug-in to the HTML table. The code is logically organized in the MVC structure:<\/p>\n<p>1. Model represents classes that contain data and that will be shown in the browser.<br>\n2. View are pages that are used to show data to the client \u2013 in this example, a JSP and a plain HTML page are used as views.<br>\n3. Controller is the logic of the application and represents servlets that handle web requests and utility functions.<\/p>\n<p>There is also one utility package containing classes transforming Java objects into JSON (this is required because the jQuery DataTables plug-in communicates with server-side code via JSON objects but not required for client-side) and We are using it with both Client-side and Server-side.<\/p>\n<p>The Model is a Student class that contains the following properties:<br>\n1. Id of the Student<br>\n2. Name of the Student<br>\n3. Gender<br>\n4. Address<br>\n5. Grade<\/p>\n<p>In this example, I have used a MYSQL Database named MyDB(for create command of database and student table I have attached studentDB.sql file. Please use this file for creation of database and student table), so I have used class called StudentModel (POJO) that contains a setter-getter for above student parameters as follows :<\/p>\n<p><strong>StudentModel.java<\/strong><br>\n<!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: java; title: ; notranslate\" title>package com;\n\npublic class StudentModel {\n\nprivate long sttudentId;\n\nprivate String firstName;\n\nprivate String lastName;\n\nprivate String address;\n\nprivate String gender;\n\nprivate String grade;\n\npublic long getSttudentId() {\nreturn sttudentId;\n}\n\npublic void setSttudentId(long sttudentId) {\nthis.sttudentId = sttudentId;\n}\n\npublic String getFirstName() {\n\nreturn firstName;\n}\n\npublic void setFirstName(String firstName) {\nthis.firstName = firstName;\n}\n\npublic String getLastName() {\nreturn lastName;\n}\n\npublic void setLastName(String lastName) {\nthis.lastName = lastName;\n}\n\npublic String getAddress() {\nreturn address;\n}\n\npublic void setAddress(String address) {\nthis.address = address;\n}\n\npublic String getGender() {\nreturn gender;\n}\n\npublic void setGender(String gender) {\nthis.gender = gender;\n}\n\npublic String getGrade() {\nreturn grade;\n}\n\npublic void setGrade(String grade) {\nthis.grade = grade;\n}\n\n}\n<\/pre>\n\n\n<!--  -->\n<p>The following sections are presented with two major cases of usage of DataTables in Java web applications.<\/p>\n<h3><strong>A) Client side processing mode ( Default usage )<\/strong><\/h3>\n<p>In this default mode, a minimum amount of code is required \u2013 the web server can generate a plain HTML table in standard format. The client-side JavaScript component will use whatever gets generated and add client-side functionalities. In this client-side mode, DataTables takes all the table rows from the<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title>&lt;tbody&gt;&lt;\/tbody&gt;<\/pre>\n<p>section and performs filtering, paging, and sorting directly on these elements as with in-memory objects. This is the fastest way to use DataTables, but it requires that the server returns all data in a single call, loads all these rows as in-memory JavaScript objects, and renders them dynamically in DOM. This might cause performance issues with the server call, and memory usage on the client. However, this minimizes the number of requests sent to the server because once the table is loaded, the server is not used at all.<\/p>\n<p>This is the small code I have Generated for Jquery Datatable to be implememted:<\/p>\n<p><strong>1) table-demo.js<\/strong><br>\n<!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: jscript; title: ; notranslate\" title>var studentTable;\n\njQuery(document).ready(function() {\n\nstudentTable = jQuery(&amp;#039;#studentListTable&amp;#039;).dataTable({\n\"bJQueryUI\" : true,\n\"sPaginationType\" : \"full_numbers\",\n\"bRetrieve\" : true,\n\"bFilter\" : true,\n\"iDisplayLength\": 10,\n\"bProcessing\" : true,\n\"bServerSide\" : false,\n\"aoColumns\" : [ { \"bSearchable\" : false,\"bVisible\" : false,\n\"asSorting\" : [ \"asc\" ] },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true }\n]\n});\n\njQuery(\".ui-corner-br\").addClass(&amp;#039;ui-widget-header_custom &amp;#039;);\n});\n\n<\/pre>\n\n\n<!--  -->\n<p>In the document-ready JavaScript event handler, the plain generated table is enhanced with the jQuery DataTables plug-in. There are parameters that are passed to the plug-in initialization function (these are parameters I always use):<\/p>\n<p>1. sPagination- Instructing the plug-in to generate pagination with numbers instead of two previous-next buttons, as is generated by default.<br>\n2. bJQueryUI- Applying standard jQueryUI styles.<br>\n3. sajaxSource- You can instruct DataTables to load data from an external source using this parameter (use aData if you want to pass data in you already have). Simply provide a url a JSON object can be obtained from. This object must include the parameter &#8216;aaData&#8217; which is the data source for the table.<br>\n4. bRetrieve- Retrieve the DataTables object for the given selector.<br>\n5. bProcessing- Enable or disable the display of a &#8216;processing&#8217; indicator when the table is being processed .<br>\n6. bServerSide- Configure DataTables to use server-side processing. Note that the sAjaxSource parameter must also be given in order to give DataTables a source to obtain the required data for each draw.<br>\n7. aoColumns- This array allows you to target a specific column, multiple columns, or all columns, using the aTargets property of each object in the array.<br>\n8. bsortable- Enable or disable sorting on this column.<br>\n9. sWidth- Defining the width of the column.<br>\n10. bSearchable- Enable or Disable filtering on the data in this column.<br>\n11. bVisible- Enable or Disable the display of this column.<br>\n12. asSorting- You can control the default sorting direction, and even alter the behaviour of the sort handler(i.e. Only aloow ascending sort etc. ) using this parameter.<\/p>\n<p>As mentioned above, the jQuery DataTables plug-in can be applied on a static HTML structure in the browser. I have generated a table structure using a JSP page to make a call to above table-demo.js shown in the listing below:<\/p>\n<p><strong>2) table-demo.jsp<\/strong><\/p>\n<p><!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: xml; title: ; notranslate\" title>&lt;%@ page\nimport=\"com.*,java.util.*\"%&gt;&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\n&lt;script type=\"text\/javascript\"&gt;\nvar basePath = &amp;#039;${pageContext.request.contextPath}&amp;#039;;\n&lt;\/script&gt;\n&lt;link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"${pageContext.request.contextPath}\/assets\/datatable\/css\/demo_table_jui.css\" &gt;\n&lt;link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"${pageContext.request.contextPath}\/assets\/jquery-ui\/css\/redmond\/jquery-ui-1.8.11.custom.css\" &gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/js\/jquery-1.5.2.min.js\" &gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/js\/jquery-ajax-form-plugin\/jquery.form.js\" &gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/datatable\/jquery.dataTables.min.js\"&gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/jquery-ui\/js\/jquery-ui-1.8.11.custom.min.js\" &gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/js\/table-demo.js\"&gt;&lt;\/script&gt;\n\n&lt;title&gt;Student Form&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;form&gt;\n&lt;div class=\"titleDiv\"&gt;Student List&lt;\/div&gt;\n&lt;div class=\"clearfix\"&gt;&lt;\/div&gt;\n&lt;div class=\"formDiv\"&gt;\n&lt;table border=\"0\" margin=\"0\" padding=\"0\" width=\"100%\"\nclass=\"dataTables_wrapper\" id=\"studentListTable\"&gt;\n&lt;thead&gt;\n&lt;tr&gt;\n&lt;th&gt;Id&lt;\/th&gt;\n&lt;th&gt;First Name&lt;\/th&gt;\n&lt;th&gt;Last Name&lt;\/th&gt;\n&lt;th&gt;Gender&lt;\/th&gt;\n&lt;th&gt;Address&lt;\/th&gt;\n&lt;th&gt;Grade&lt;\/th&gt;\n&lt;\/tr&gt;\n&lt;\/thead&gt;\n&lt;tbody&gt;\n&lt;%\nif(request.getAttribute(\"studentList\") != null){\nList&lt;StudentModel&gt; studentList = (List&lt;StudentModel&gt;)\nrequest.getAttribute(\"studentList\");\n%&gt;\n&lt;%\nif( studentList != null ){\nfor (StudentModel student: studentList){\n%&gt;\n&lt;tr&gt;\n&lt;td&gt;&lt;%=student.getSttudentId()%&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;%=student.getFirstName()%&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;%=student.getLastName()%&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;%=student.getGender()%&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;%=student.getAddress()%&gt;&lt;\/td&gt;\n&lt;td&gt;&lt;%=student.getGrade()%&gt;&lt;\/td&gt;\n\n&lt;\/tr&gt;\n&lt;%}\n}\n\n}%&gt;\n\n&lt;\/tbody&gt;\n&lt;\/table&gt;\n&lt;\/div&gt;\n&lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n\n\n<!--  -->\n<p>In this JSP page is included all the necessary JavaScript libraries, and HTML code for the student table is generated. For demonstration purposes, a simple loop generates a TR for each student that is returned by the TableDemoAction class. However, in your applications, you can use any server-side processing you want (JavaBeans, JSTL components, etc.) because the jQuery DataTables plug-in is independent of the applied server-side technology.<\/p>\n<p>This is my action (controller) class called TableDemoAction which make a call to list of students which in turn returns the list of students. Also forword request to JSP page table-demo.jsp.<\/p>\n<p><strong>3) TableDemoAction.java<\/strong><br>\n<!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: java; title: ; notranslate\" title>package com;\n\nimport java.io.IOException;\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\nimport java.sql.Statement;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport javax.servlet.RequestDispatcher;\nimport javax.servlet.ServletException;\nimport javax.servlet.http.HttpServlet;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\n\n@SuppressWarnings(\"serial\")\npublic class TableDemoAction extends HttpServlet {\n\nprivate String STUDENT_ID_LIST = \"studentList\";\n\npublic void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {\n\nList&lt;StudentModel&gt; studentList = null;\ntry {\nstudentList = selectStudentInfo();\n} catch (SQLException e) {\ne.printStackTrace();\n}\n\nString destination = \"\/WEB-INF\/views\/com\/table-demo.jsp\";\nrequest.setAttribute(STUDENT_ID_LIST, studentList);\n\nRequestDispatcher rd = request.getRequestDispatcher(destination);\nrd.forward(request, response);\n\n}\n\npublic List&lt;StudentModel&gt; selectStudentInfo() throws SQLException {\n\nList&lt;StudentModel&gt; al = new ArrayList&lt;StudentModel&gt;();\n\n\/\/ @formatter:off\n\nString query =\n\n\" SELECT id,firstName,lastName,gender,address,grade \" +\n\n\" FROM \" +\n\n\" student \" +\n\n\" order by id asc \";\n\n\/\/ @formatter:on\nString connectionURL = \"jdbc:mysql:\/\/localhost:3306\/MyDB?\nuser=root&amp;password=mobisoft\";\ntry {\nClass.forName(\"com.mysql.jdbc.Driver\");\n} catch (ClassNotFoundException e) {\ne.printStackTrace();\n}\n\nConnection connection = DriverManager.getConnection(connectionURL);\nStatement statement = connection.createStatement();\nResultSet resultSet = statement.executeQuery(query);\n\nwhile (resultSet.next()) {\n\nStudentModel student = new StudentModel();\nstudent.setSttudentId(resultSet.getLong(\"id\"));\nstudent.setFirstName(resultSet.getString(\"firstName\"));\nstudent.setLastName(resultSet.getString(\"lastName\"));\nstudent.setGender(resultSet.getString(\"gender\"));\nstudent.setAddress(resultSet.getString(\"address\"));\nstudent.setGrade(resultSet.getString(\"grade\"));\n\nal.add(student);\n}\n\nresultSet.close();\nstatement.close();\n\nreturn al;\n\n}\n\n}\n\n<\/pre>\n\n\n<!--  -->\n<p>Instead of the plain HTML table, the following component is shown on the client side:<\/p>\n<p><a class=\"hs-rsp-popup\" href=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage.png\" data-abc=\"true\"><noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2781\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage.png\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage-300x82.png 300w\" alt width=\"650\" height=\"179\"><\/noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2781 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E 650w\" alt width=\"650\" height=\"179\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage-300x82.png 300w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage.png\"><\/a><\/p>\n<p>All actions you see in the component are implemented on the client-side (e.g., when you enter text in the text box, TR elements are filtered). This is the fastest way for the user, under the assumption that the time required to load the table is not too big. If you have a huge amount of data, you might consider using DataTables in AJAX mode where only partial results are returned to the plug-in.<\/p>\n<p>You can see a complete list of additional DataTable plugins on the DataTables site. All these plug-ins are additional add-ons for DataTables, but you can also use the powerful DataTables API to customize behavior. An example of the plain table enhanced with a few mentioned plugins is shown in the following figure:<\/p>\n<p><a class=\"hs-rsp-popup\" href=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1.png\" data-abc=\"true\"><noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2783\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1.png\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1-300x82.png 300w\" alt width=\"650\" height=\"179\"><\/noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2783 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E 650w\" alt width=\"650\" height=\"179\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1-300x82.png 300w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage1.png\"><\/a><\/p>\n<p>If you have a reasonable amount of records in the table you do not need to worry about these functionalities. Just render a plain table and apply some combination of plug-ins that you need.<\/p>\n<p>However, if you have a lot of records that are shown in the table and you want to avoid complex JavaScript processing in the browser, you can implement the processing logic on the server-side (e.g., in some servlet), and setup DataTables to query the server via AJAX calls in order to take information that should be displayed. This mode is described in the following section.<\/p>\n<p><a id=\"link39249\" style=\"display: none;\" href=\"http:\/\/domyessayonline.net\/\" data-abc=\"true\">do my essay for me free<\/a><script type=\"text\/javascript\"> if (1==1) {document.getElementById(\"link39249\").style.display=\"none\";}<\/script><\/p>\n<h3><strong>B) Jquery Datatable with Server-side processing<\/strong><\/h3>\n<p>The jQuery DataTables plug-in is an excellent client-side component that can be used to create rich-functional tables in a web browser. This plug-in adds a lot of functionalities to plain HTML tables. Although, by default it is pure client side, it might be configured to use data from the server via AJAX calls in order to improve performance. However, to integrate DataTables with server-side code, the developer must know the protocols and parameters that are sent by DataTables and how to use them on the server side.<\/p>\n<p>In this mode, instead of taking the complete page at once, several smaller requests are sent whenever new information is required, and minimal amount of data is returned from the server. This example, calls the \/DatatableDemoAction URL and sends information about the student.<\/p>\n<p>Lets Start with the Jquery :<br>\nThis is the small amount of code that I have Generated for Jquery Datatable with Server-Side Processing to be implememted:<\/p>\n<p><strong>1) datatable-demo.js<\/strong><br>\n<!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: jscript; title: ; notranslate\" title>var studentTable;\n\njQuery(document).ready(function() {\n\nstudentTable = jQuery(&amp;#039;#studentListTable&amp;#039;).dataTable({\n\n\"bJQueryUI\" : true,\n\"sPaginationType\" : \"full_numbers\",\n\"iDisplayLength\": 10,\n\"bProcessing\" : true,\n\"bServerSide\" : true,\n\"sAjaxSource\" : basePath +\"\/com\/DatatableDemoAction.java\",\n\n\"aoColumns\" : [{\"bSearchable\" : false, \"bVisible\" : false, \"asSorting\" : [ \"asc\" ] },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"10%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true },\n{\"sWidth\" : \"20%\",\"bSortable\" : true }\n]\n});\njQuery(\".ui-corner-br\").addClass(&amp;#039;ui-widget-header_custom &amp;#039;);\n\n});\n\n<\/pre>\n\n\n<!--  -->\n<p>In the document-ready JavaScript event handler, the plain generated table is enhanced with the jQuery DataTables plug-in. The parameters that are passed to the plug-in initialization function I already have discussed above the only paramter I would like to tell you is :<br>\n1. bServerSide- Configure DataTables to use server-side processing. Note that the sAjaxSource parameter must also be given in order to give DataTables a source to obtain the required data for each draw. It must be true for server-side processing.<br>\nAs mentioned above, the jQuery DataTables plug-in can be applied on a static HTML structure in the browser. I have generated a table structure using a JSP page to make a call to above <strong>datatable-demo.js<\/strong> shown in the listing below:<\/p>\n<p><strong>2) datatable-demo.jsp<\/strong><\/p>\n<p><!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: xml; title: ; notranslate\" title>&lt;%@ page\nimport=\"java.util.*\"%&gt;&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\n&lt;script type=\"text\/javascript\"&gt;\nvar basePath = &amp;#039;${pageContext.request.contextPath}&amp;#039;;\n&lt;\/script&gt;\n&lt;link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"${pageContext.request.contextPath}\/assets\/datatable\/css\/demo_table_jui.css\" &gt;\n&lt;link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"${pageContext.request.contextPath}\/assets\/jquery-ui\/css\/redmond\/jquery-ui-1.8.11.custom.css\" &gt;\n&lt;script type=\"text\/javascript\" src=\" $pageContext.request.contextPath}\/assets\/js\/jquery-1.5.2.min.js\" &gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/js\/jquery-ajax-form-plugin\/jquery.form.js\" &gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/datatable\/jquery.dataTables.min.js\"&gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/jquery-ui\/js\/jquery-ui-1.8.11.custom.min.js\" &gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/javascript\" src=\"${pageContext.request.contextPath}\/assets\/js\/datatable-demo.js\"&gt;&lt;\/script&gt;\n\n&lt;title&gt;Student Form&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;form&gt;\n&lt;div class=\"titleDiv\"&gt;Student List&lt;\/div&gt;\n&lt;div class=\"clearfix\"&gt;&lt;\/div&gt;\n\n&lt;div class=\"formDiv\"&gt;\n&lt;table border=\"0\" margin=\"0\" padding=\"0\" width=\"100%\"\nclass=\"dataTables_wrapper\" id=\"studentListTable\"&gt;\n&lt;thead&gt;\n&lt;tr&gt;\n&lt;th&gt;Id&lt;\/th&gt;\n&lt;th&gt;First Name&lt;\/th&gt;\n&lt;th&gt;Last Name&lt;\/th&gt;\n&lt;th&gt;Gender&lt;\/th&gt;\n&lt;th&gt;Address&lt;\/th&gt;\n&lt;th&gt;Grade&lt;\/th&gt;\n&lt;\/tr&gt;\n&lt;\/thead&gt;\n&lt;tbody&gt;\n&lt;\/tbody&gt;\n&lt;\/table&gt;\n&lt;\/div&gt;\n&lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n\n\n<!--  -->\n<p>In this JSP page is included all the necessary JavaScript libraries, and HTML code for the student table to be generated. For demonstration purposes, I have used server-side processing because the jQuery DataTables plug-in is independent of the applied server-side technology.<\/p>\n<p>In the Third step we have created class <strong>DemoAction.java<\/strong> which makes a call to the JSP page (<strong>datatable-demo.jsp<\/strong>) which in turn call to JS file (<strong>datatable-demo.js<\/strong>) and this JS in turn makes call to DatatableDemoAction.java.<\/p>\n<p><strong>3) DemoAction.java<\/strong><\/p>\n<p><!--\n\n\n<pre> -->\n\n<\/p><pre class=\"brush: java; title: ; notranslate\" title>package com;\n\nimport java.io.IOException;\n\nimport javax.servlet.RequestDispatcher;\nimport javax.servlet.ServletException;\nimport javax.servlet.http.HttpServlet;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\n\n@SuppressWarnings(\"serial\")\npublic class DemoAction extends HttpServlet {\n\n@Override\npublic void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {\n\nString destination = \"\/WEB-INF\/views\/com\/datatable-demo.jsp\";\n\nRequestDispatcher rd = request.getRequestDispatcher(destination);\nrd.forward(request, response);\n}\n\n}\n\n<\/pre>\n\n\nLast step would be to create a handler\/web service which we would be passing in the argument sAjaxSource of datatable. Remember that the response should be a JSON formatted text as datatable only reads JSON in aData parameter. <strong>4) DatatableDemoAction.java<\/strong>\n\n\n<pre class=\"brush: java; title: ; notranslate\" title>package com;\n\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\nimport javax.servlet.ServletException;\nimport javax.servlet.http.HttpServlet;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\n@SuppressWarnings(\"serial\")\npublic class DatatableDemoAction extends HttpServlet {\n\nprivate String SEARCH_TERM;\n\nprivate String COL_NAME;\n\nprivate String DIR;\n\nprivate int START;\n\nprivate int AMOUNT;\n\npublic void doGet(HttpServletRequest request, HttpServletResponse response)\nthrows ServletException, IOException {\n\nString[] cols = { \"id\", \"firstName\", \"lastName\", \"gender\", \"address\",\n\"grade\" };\n\nJSONObject result = new JSONObject();\nint amount = 10;\nint start = 0;\nint col = 0;\nString dir = \"asc\";\nString sStart = request.getParameter(\"iDisplayStart\");\nString sAmount = request.getParameter(\"iDisplayLength\");\nString sCol = request.getParameter(\"iSortCol_0\");\nString sdir = request.getParameter(\"sSortDir_0\");\n\nif (sStart != null) {\nstart = Integer.parseInt(sStart);\nif (start &lt; 0) {\nstart = 0;\n}\n}\nif (sAmount != null) {\namount = Integer.parseInt(sAmount);\nif (amount &lt; 10 || amount &gt; 50) {\namount = 10;\n}\n}\nif (sCol != null) {\ncol = Integer.parseInt(sCol);\nif (col &lt; 0 || col &gt; 5)\ncol = 0;\n}\nif (sdir != null) {\nif (!sdir.equals(\"asc\"))\ndir = \"desc\";\n}\n\nString colName = cols[col];\nint total = -1;\ntry {\ntotal = getTotalRecordCount();\n} catch (SQLException e1) {\ne1.printStackTrace();\n}\n\nAMOUNT = amount;\nSEARCH_TERM = request.getParameter(\"sSearch\");\nCOL_NAME = colName;\nDIR = dir;\nSTART = start;\n\ntry {\nresult = getStudentData(total, request);\n} catch (ClassNotFoundException e) {\ne.printStackTrace();\n} catch (SQLException e) {\ne.printStackTrace();\n}\n\nresponse.setContentType(\"application\/json\");\nresponse.setHeader(\"Cache-Control\", \"no-store\");\nPrintWriter out = response.getWriter();\n\nout.print(result);\n\n}\n\npublic JSONObject getStudentData(int total, HttpServletRequest request)\nthrows SQLException, ClassNotFoundException {\n\nint totalAfterFilter = total;\nJSONObject result = new JSONObject();\nJSONArray array = new JSONArray();\nString searchSQL = \"\";\n\ntry {\nClass.forName(\"com.mysql.jdbc.Driver\");\n} catch (ClassNotFoundException e) {\ne.printStackTrace();\n}\nString connectionURL = \"jdbc:mysql:\/\/localhost:3306\/MyDB?\nuser=root&amp;password=mobisoft\";\nConnection connection = DriverManager.getConnection(connectionURL);\n\/\/ @formatter:off\nString sql = \"SELECT \" + \"id, firstName, lastName, gender, address, \"\n+ \"grade \" + \"FROM \" + \"student \" + \"WHERE \"\n+ \"is_deleted = ? \";\n\n\/\/ @formatter:on\n\nString globeSearch = \" AND (firstName like &amp;#039;%\" + SEARCH_TERM + \"%&amp;#039;\"\n+ \"or lastName like &amp;#039;%\" + SEARCH_TERM + \"%&amp;#039;\"\n+ \"or gender like &amp;#039;%\" + SEARCH_TERM + \"%&amp;#039;\"\n+ \"or address like &amp;#039;%\" + SEARCH_TERM + \"%&amp;#039;\"\n+ \"or grade like &amp;#039;%\" + SEARCH_TERM + \"%&amp;#039;)\";\n\nif (SEARCH_TERM != \"\") {\nsearchSQL = globeSearch;\n}\n\nsql += searchSQL;\nsql += \" order by \" + COL_NAME + \" \" + DIR;\n\nsql += \" limit \" + START + \", \" + AMOUNT;\n\nPreparedStatement statement = connection.prepareStatement(sql);\nstatement.setBoolean(1, false);\n\nResultSet rs = statement.executeQuery();\n\nwhile (rs.next()) {\nJSONArray ja = new JSONArray();\n\nja.put(rs.getString(\"id\"));\nja.put(rs.getString(\"firstName\"));\nja.put(rs.getString(\"lastName\"));\nja.put(rs.getString(\"gender\"));\nja.put(rs.getString(\"address\"));\nja.put(rs.getString(\"grade\"));\n\narray.put(ja);\n}\nstatement.close();\nrs.close();\n\n\/\/ @formatter:off\nString query = \"SELECT \" + \"COUNT(*) as count \" + \"FROM \" + \"student \"\n+ \"WHERE \" + \"is_deleted = ? \";\n\/\/ @formatter:on\n\nif (SEARCH_TERM != \"\") {\nquery += searchSQL;\n\nPreparedStatement stmt = connection.prepareStatement(query);\nstmt.setBoolean(1, false);\n\nResultSet resultSet = stmt.executeQuery();\n\nif (resultSet.next()) {\ntotalAfterFilter = resultSet.getInt(\"count\");\n}\nstmt.close();\nresultSet.close();\nconnection.close();\n}\ntry {\nresult.put(\"iTotalRecords\", total);\nresult.put(\"iTotalDisplayRecords\", totalAfterFilter);\nresult.put(\"aaData\", array);\n} catch (Exception e) {\n\n}\n\nreturn result;\n}\n\npublic int getTotalRecordCount() throws SQLException {\n\nint total = -1;\n\/\/ @formatter:off\nString sql = \"SELECT \" + \"COUNT(*) as count \" + \"FROM \" + \"student \"\n+ \"WHERE \" + \"is_deleted = ? \";\n\n\/\/ @formatter:on\n\nString connectionURL = \"jdbc:mysql:\/\/localhost:3306\/MyDB?\nuser=root&amp;password=mobisoft\";\ntry {\nClass.forName(\"com.mysql.jdbc.Driver\");\n} catch (ClassNotFoundException e) {\ne.printStackTrace();\n}\n\nConnection connection = DriverManager.getConnection(connectionURL);\n\nPreparedStatement statement = connection.prepareStatement(sql);\n\nstatement.setBoolean(1, false);\nResultSet resultSet = statement.executeQuery();\n\nif (resultSet.next()) {\ntotal = resultSet.getInt(\"count\");\n}\nresultSet.close();\nstatement.close();\nconnection.close();\n\nreturn total;\n}\n\n}\n\n<\/pre>\n\n\n<!--  -->\n<p><strong>Parameters sent to the server<\/strong><\/p>\n<p>The following information is sent to the server for each draw request. Your server-side script must use this information to obtain the data required for the draw.<\/p>\n<p>1. iDisplayStart -Define the starting point for data display when using DataTables with pagination.<br>\n2. iDisplayLength \u2013 Number of rows to display on a single page when using pagination.<br>\n3. iSortCol_(int) \u2013 Column being sorted on (you will need to decode this number for your database).<br>\n4. sSortDir_(int) \u2013 Direction to be sorted \u2013 \u201cdesc\u201d or \u201casc\u201d.<br>\n5. sSearch \u2013 Global search field.<br>\n6. iColumns- Number of columns being displayed (useful for getting individual column search info).<\/p>\n<p><strong>Reply from the server<\/strong><\/p>\n<p>In reply to each request for information that DataTables makes to the server, it expects to get a well formed JSON object with the following parameters.<br>\n1. iTotalRecords- Total records, before filtering (i.e. the total number of records in the database).<br>\n2. iTotalDisplayRecords- Total records, after filtering (i.e. the total number of records after filtering has been applied \u2013 not just the number of records being returned in this result set).<br>\n3. aaData- The data in a 2D array. Note that you can change the name of this parameter with sAjaxDataProp.<\/p>\n<p>All actions you see in the component are implemented on the Server-side. You can see a complete list of additional DataTable plugins on the DataTables site. All these plug-ins are additional add-ons for DataTables, but you can also use the powerful DataTables API to customize behavior. An example of the plain table enhanced with a few mentioned plugins is shown in the following figure:<\/p>\n<p><a class=\"hs-rsp-popup\" href=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2.png\" data-abc=\"true\"><noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2787\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2.png\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2-300x82.png 300w\" alt width=\"650\" height=\"179\"><\/noscript><img decoding=\"async\" class=\"aligncenter size-full wp-image-2787 lazyload\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E\" sizes=\"(max-width: 650px) 100vw, 650px\" srcset=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20650%20179%22%3E%3C%2Fsvg%3E 650w\" alt width=\"650\" height=\"179\" data-srcset=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2.png 650w, https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2-300x82.png 300w\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/tableImage2.png\"><\/a><\/p>\n<p>In this example we have used the JSON library for serializing Java objects to JSON, but you can use any other JSON serialization library instead.<\/p>\n<p>You can find some example on the <a title=\"Datatable Server-Side\" href=\"https:\/\/datatables.net\/\" rel=\"noopener nofollow\" data-abc=\"true\">DataTables site<\/a>. The only important thing is that you return a JSON response with objects that match the current state on the table.<\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p>This example shows how you can create effective, fully functional tables in a Java web application using the jQuery DataTables plug-in. Using the code examples in the article, you can significantly enhance the look and functionalities of your web application. I recommend that you try it \u2013 when you integrate jQuery DataTables in a few tables in your application, you will see that the implementation is straightforward and that you will be, with some practice, able to implement a lot of functionalities with very little effort.<\/p>\n<p>You can download the code example in the attached project that was created in the Eclipse Java EE IDE for Web Developers, that runs on a Tomcat 6.0 web server and I have used <strong>Ant<\/strong> for project deployment. I suggest you create a new project, configure it with your tomcat (no need to go with <strong>Ant<\/strong> if you do not the setting of <strong>Ant<\/strong>, so remove that build.properties file and build.xml file and configure this project with your local tomcat setting), and add classes that you can find in the project. I hope that this example will help you to create better table interfaces.<\/p>\n<p>You can download the <a href=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2012\/11\/sample-project.zip\" data-abc=\"true\"> Datatable source code from here.<\/a><\/p>\n<div style=\"display: none;\">765qwerty765<\/div>\n<div class=\"modern-author-card\">\n    <div class=\"author-card-content\">\n        <div class=\"author-info-section\">\n            <div class=\"author-avatar\">\n                <noscript><img decoding=\"async\" src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2022\/04\/Pritam1.jpg\" alt=\"Pritam Barhate\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"Pritam Barhate\" data-src=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2022\/04\/Pritam1.jpg\" class=\" lazyload\">\n            <\/div>\n            <div class=\"author-details\">\n                <h3 class=\"author-name\">Pritam Barhate<\/h3>\n                <p class=\"author-title\">Head of Technology Innovation<\/p>\n                <a href=\"javascript:void(0);\" class=\"read-more-link read-more-btn\" onclick=\"toggleAuthorBio(this); return false;\">Read more <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"expand\" class=\"read-more-arrow down-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"expand\" class=\"read-more-arrow down-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <div class=\"author-bio-expanded\">\n                    <p>Pritam Barhate, with an experience of 14+ years in technology, heads Technology Innovation at <a href=\"https:\/\/mobisoftinfotech.com\" target=\"_blank\" rel=\"noopener\">Mobisoft Infotech<\/a>. He has a rich experience in design and development. He has been a consultant for a variety of industries and startups. At Mobisoft Infotech, he primarily focuses on technology resources and develops the most advanced solutions.<\/p>\n                    <div class=\"author-social-links\">\n                        <div class=\"social-icon\">\n                            <a href=\"https:\/\/www.linkedin.com\/in\/pritam-barhate-90b93414\/\" target=\"_blank\" rel=\"nofollow noopener\"><i class=\"icon-sprite linkedin\"><\/i><\/a>\n                            <a href=\"https:\/\/twitter.com\/pritambarhate\" target=\"_blank\" rel=\"nofollow noopener\"><i class=\"icon-sprite twitter\"><\/i><\/a>\n                        <\/div>\n                    <\/div>\n                    <a href=\"javascript:void(0);\" class=\"read-more-link read-less-btn\" onclick=\"toggleAuthorBio(this); return false;\" style=\"display: none;\">Read less <noscript><img decoding=\"async\" src=\"\/assets\/images\/blog\/Vector.png\" alt=\"collapse\" class=\"read-more-arrow up-arrow\"><\/noscript><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" alt=\"collapse\" class=\"read-more-arrow up-arrow lazyload\" data-src=\"\/assets\/images\/blog\/Vector.png\"><\/a>\n                <\/div>\n            <\/div>\n        <\/div>\n        <div class=\"share-section\">\n            <span class=\"share-label\">Share Article<\/span>\n            <div class=\"social-share-buttons\">\n                <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Fweb-programming%2Fjquery-datatable-ajax-tutorial-with-example-project\" target=\"_blank\" class=\"share-btn facebook-share\"><i class=\"fa fa-facebook-f\"><\/i><\/a>\n                <a href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fmobisoftinfotech.com%2Fresources%2Fblog%2Fweb-programming%2Fjquery-datatable-ajax-tutorial-with-example-project\" target=\"_blank\" class=\"share-btn linkedin-share\"><i class=\"fa fa-linkedin\"><\/i><\/a>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Hi, The goal of this blog is to show how you can implement fully functional, high-performance tables using the jQuery DataTables plug-in. Basically, There are many ways to get your data into DataTables, and if you are working with large databases, you might want to consider using the server-side options that DataTables provides. Basically [&hellip;]<\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[182],"tags":[],"class_list":["post-2755","post","type-post","status-publish","format-standard","hentry","category-web-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Jquery Datatable Ajax Tutorial With Example Project<\/title>\n<meta name=\"description\" content=\"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Jquery Datatable Ajax Tutorial With Example Project\" \/>\n<meta property=\"og:description\" content=\"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\" \/>\n<meta property=\"og:site_name\" content=\"Mobisoft Infotech\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-29T08:38:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-21T11:35:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\" \/>\n<meta name=\"author\" content=\"suraj.kurrewar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"suraj.kurrewar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\"},\"author\":{\"name\":\"suraj.kurrewar\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6\"},\"headline\":\"jQuery Datatable Ajax Tutorial With Example Project\",\"datePublished\":\"2017-04-29T08:38:03+00:00\",\"dateModified\":\"2024-08-21T11:35:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\"},\"wordCount\":2130,\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\",\"articleSection\":[\"Web Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\",\"name\":\"Jquery Datatable Ajax Tutorial With Example Project\",\"isPartOf\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\",\"datePublished\":\"2017-04-29T08:38:03+00:00\",\"dateModified\":\"2024-08-21T11:35:34+00:00\",\"author\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6\"},\"description\":\"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.\",\"breadcrumb\":{\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\",\"contentUrl\":\"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png\",\"width\":670,\"height\":274,\"caption\":\"Documents\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobisoftinfotech.com\/resources\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"jQuery Datatable Ajax Tutorial With Example Project\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#website\",\"url\":\"https:\/\/mobisoftinfotech.com\/resources\/\",\"name\":\"Mobisoft Infotech\",\"description\":\"Discover Mobility\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6\",\"name\":\"suraj.kurrewar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g\",\"caption\":\"suraj.kurrewar\"},\"sameAs\":[\"http:\/\/www.mobisoftinfotech.com\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Jquery Datatable Ajax Tutorial With Example Project","description":"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project","og_locale":"en_US","og_type":"article","og_title":"Jquery Datatable Ajax Tutorial With Example Project","og_description":"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.","og_url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project","og_site_name":"Mobisoft Infotech","article_published_time":"2017-04-29T08:38:03+00:00","article_modified_time":"2024-08-21T11:35:34+00:00","og_image":[{"url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png","type":"","width":"","height":""}],"author":"suraj.kurrewar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"suraj.kurrewar","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#article","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project"},"author":{"name":"suraj.kurrewar","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6"},"headline":"jQuery Datatable Ajax Tutorial With Example Project","datePublished":"2017-04-29T08:38:03+00:00","dateModified":"2024-08-21T11:35:34+00:00","mainEntityOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project"},"wordCount":2130,"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png","articleSection":["Web Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project","url":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project","name":"Jquery Datatable Ajax Tutorial With Example Project","isPartOf":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage"},"image":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage"},"thumbnailUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png","datePublished":"2017-04-29T08:38:03+00:00","dateModified":"2024-08-21T11:35:34+00:00","author":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6"},"description":"This blog shows how you can implement fully functional, high performance tables using the jQuery DataTables plug-in.","breadcrumb":{"@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#primaryimage","url":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png","contentUrl":"https:\/\/mobisoftinfotech.com\/resources\/wp-content\/uploads\/2017\/04\/image-7-copy.png","width":670,"height":274,"caption":"Documents"},{"@type":"BreadcrumbList","@id":"https:\/\/mobisoftinfotech.com\/resources\/blog\/web-programming\/jquery-datatable-ajax-tutorial-with-example-project#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobisoftinfotech.com\/resources\/"},{"@type":"ListItem","position":2,"name":"jQuery Datatable Ajax Tutorial With Example Project"}]},{"@type":"WebSite","@id":"https:\/\/mobisoftinfotech.com\/resources\/#website","url":"https:\/\/mobisoftinfotech.com\/resources\/","name":"Mobisoft Infotech","description":"Discover Mobility","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobisoftinfotech.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/mobisoftinfotech.com\/resources\/#\/schema\/person\/6cc80fe99af81900f7a6b87a4a3998a6","name":"suraj.kurrewar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/95f208ea6358426a062fb71b766e4cf68be396a97392abcacdbb52f4854f56aa?s=96&r=g","caption":"suraj.kurrewar"},"sameAs":["http:\/\/www.mobisoftinfotech.com\/"]}]}},"_links":{"self":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/comments?post=2755"}],"version-history":[{"count":90,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2755\/revisions"}],"predecessor-version":[{"id":30628,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/posts\/2755\/revisions\/30628"}],"wp:attachment":[{"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/media?parent=2755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/categories?post=2755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobisoftinfotech.com\/resources\/wp-json\/wp\/v2\/tags?post=2755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}