How to load XML data in jQuery UI autocomplete with PHP

jQuery UI autocompletes enable a textbox to show a suggestion list based on the input.

It allows the loading of suggestion list using AJAX.

AJAX response must be in a defined format otherwise, the list wouldn’t show.

You can load XML data if available.

In this tutorial, I show how you can load XML file data in jQuery UI autocomplete using AJAX and PHP.

How to load XML data in jQuery UI autocomplete with PHP

Read more

How to add Select2 on Dynamic element – jQuery

Select2 jQuery plugin is easy to add on the <select > element. Need to call the select2() method on the selector to initialize.

If you adding select2 on a class or select element and when you add an element dynamically then select2 is not initialized on that element.

In this tutorial, I show how you can initialize select2 on dynamically created HTML <select > element using jQuery.

I am loading select2 data using jQuery AJAX in the example.

How to add select2 on Dynamic element - jQuery

Read more

Date range search in DataTable with jQuery AJAX and PHP

DataTable comes with a single search box that you can use to search on all or specific fields and display filtered records.

You can add custom elements according to your requirements and use them with DataTable.

In this tutorial, I show how you can implement a date range search in DataTable with jQuery AJAX and PHP. I am using jQuery UI for adding date picker.
Date range search in DataTable with jQuery AJAX and PHP

Read more

How to Send AJAX request with CSRF token in CodeIgniter 3

Cross-Site Request Forgery (CSRF) is a way to trick the server that a request sent to it is legitimate while it actually is an unauthorized attempt.

In CodeIgniter, CSRF protection is not enabled by default.

If it is been enabled then CodeIgniter generates a hash for each active user and this is used to verify the request.

Require to send the hash with the AJAX request otherwise, it gives an error – “The action you have requested is not allowed.”.

In this tutorial, I show how you can enable CSRF protection and regenerate hash for the next AJAX request and pass hash in AJAX request in the CodeIgniter project.

How to Send AJAX request with CSRF token in CodeIgniter 3

Read more