DataTables AJAX Pagination with Search and Sort in CodeIgniter 4

DataTables is a widely used jQuery plugin for pagination. After initialization, it adds a search box and column sort on the header column.

It allows adding pagination with and without AJAX.

In this tutorial, I show how you can implement DataTables AJAX pagination with search and sort in the CodeIgniter 4 project.

DataTables AJAX Pagination with Search and Sort in CodeIgniter 4

Read more

How to Load data using jQuery AJAX in Select2 – CodeIgniter 4

With the Select2 jQuery plugin, you can customize the default HTML select element.

It allows searching, multiple option selection, loading data using jQuery AJAX, etc.

In this tutorial, I show how you can load MySQL database data remotely using jQuery AJAX in the Select2 plugin in the CodeIgniter 4 project.

How to Load data using jQuery AJAX in Select2 – CodeIgniter 4

Read more

How to upload a file using jQuery AJAX in CodeIgniter 4

With AJAX you can perform an action on the server without refreshing the whole page.

You can use it to fetch data, import file data, upload files, etc.

In this tutorial, I am using it to upload a file and display a preview if the file is an image otherwise display a link in the CodeIgniter 4 project.

I have enabled CSRF token in the CodeIgniter project.

How to upload a file using jQuery AJAX in CodeIgniter 4

Read more

How to Send AJAX request with CSRF token in CodeIgniter 4

Cross-Site Request Forgery (CSRF) requests are a type of malicious exploit whereby unauthorized commands are performed on behalf of an authenticated user.

CodeIgniter 4 provides protection from CSRF attacks. But it is not enabled by default same as CodeIgniter 3.

The token is generated for each user and it is managed by CodeIgniter to verify the user request.

In this tutorial, I show how you can enable CSRF protection and send AJAX request with CSRF token in the CodeIgniter 4 project.

How to Send AJAX request with CSRF token in CodeIgniter 4

Read more

Edit Delete DataTables record with AJAX and PHP

With the use of the DataTables jQuery plugin, you can list your records in pagination format.

You can add HTML elements like – buttons, link, image, etc with a record.

For this need to pass element in HTML string format from the PHP script.

In this tutorial, I show how you can add edit and delete buttons in the Datatables AJAX pagination with PHP.

NOTE – I am using the Bootstrap modal to update a record.

Edit delete DataTables record with AJAX and PHP

Read more