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