How to use Datatable with Ajax when creating plugin on WordPress?

Solution to my own problem: Enqueue your custom file.js and localize admin-ajax.php. index.php function script_enqueue() { // Register the JS file with a unique handle, file location, and an array of dependencies wp_register_script(“dt_csc”, plugin_dir_url(__FILE__). ‘js/cdt.js’, array(‘jquery’)); // localize the script to your domain name, so that you can reference the url to admin-ajax.php file easily … Read more

TypeError: $(…).DataTable is not a function

CAUSE There could be multiple reasons for this error. jQuery DataTables library is missing. jQuery library is loaded after jQuery DataTables. Multiple versions of jQuery library is loaded. SOLUTION Include only one version of jQuery library version 1.7 or newer before jQuery DataTables. For example: See jQuery DataTables: Common JavaScript console errors for more information … Read more