Select2 and CodeIgniter 4: A Guide to Loading Data with jQuery AJAX

The functionality of common HTML select elements is improved by the Select2 jQuery plugin. You can quickly look up and choose multiple items from a dropdown list using Select2.

It allows loading data using jQuery AJAX.

This tutorial focuses on integrating the Select2 plugin with CodeIgniter 4 and using jQuery AJAX to load data from a MySQL database. To ensure secure communication, the tutorial also covers how to pass the CSRF token with the AJAX request.

If you’re unfamiliar with enabling CSRF protection, then you can view this tutorial which provides a helpful resource to guide you through the process.

Select2 and CodeIgniter 4: A Guide to Loading Data with jQuery AJAX

 

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

Datatables AJAX pagination with Search and Sort – Laravel 7

DataTables is a jQuery library that is used to create pagination. It comes with various features – pagination, sorting, search, etc.

You can load data with and without AJAX.

In this tutorial, I show how you can create AJAX pagination with search and sort using DataTables in Laravel 7.

I am not using Laravel package for DataTables.

Datatables AJAX pagination with Search and Sort - Laravel 7

Read more