Change Selected option in Select2 Dropdown with jQuery

Select2 is a jQuery plugin that customizes HTML select element and makes it more user-friendly.

It adds search features and allows to add an image with options.

The HTML select element option can easily set selected using jQuery – $(selector).val(option-value);.

But this does not directly work with the Select2 dropdown element.

In this tutorial, I show how you can dynamically set an option selected in Select2 with jQuery.

Change Selected option in Select2 Dropdown with jQuery

Read more

Loading XML file data in Select2 with jQuery AJAX and PHP

Autocomplete search makes it easier to find an item from the long list of available items.

It displays suggestions based on the typed searched text.

If your data available in XML format then also you can use it for autocomplete searching.

With the use of XPath navigate on the XML data node and search the value.

In this tutorial, I am using the select2 plugin for autocomplete data with jQuery AJAX.

Loading XML file data in select2 with jQuery AJAX and PHP

Read more

How to Send AJAX request from Plugin in WordPress

Plugin is used to add features to the site without modifying the core code.

While building plugin you can also use AJAX to save the form after submit, retrieve data from MySQL database, file upload, etc.

In the plugin, AJAX is implemented as same as implemented on the theme.

In this tutorial, I show how you can create a custom plugin and send an AJAX request in WordPress.

Read more

How to add Custom Filter in DataTable – AJAX and PHP

DataTables plugin brings enhanced functionality and interactivity to HTML tables, offering features like pagination, sorting, and searching across all columns. By default, DataTables provides a search control that allows users to find values across the entire table and presents a filter list for easy data filtering.

However, the beauty of DataTables lies in its customizability, empowering developers to create tailor-made search filters based on specific record requirements, such as date filtering or single field search.

In this tutorial, we will delve into the process of adding custom filters to DataTables and utilizing AJAX for seamless data retrieval. Let’s get started and elevate the power of DataTables with personalized filtering capabilities.

How to add Custom Filter in DataTable – AJAX and PHP

Read more