Skip to content
Advertisement

How do I make my dataTable sorted if the data is ACTIVE or INACTIVE using JQuery and Ajax?

My goal is that I want to sort my data if it is still ACTIVE or INACTIVE. But the result I’ve got is that if I click active it only shows the active data and when inactive it doesn’t show. I don’t have syntax errors but logical errors. I am using PHP, JQuery/AJAX.

Here is my code in HTML

JavaScript

Here is my code in Javascript/Jquery

JavaScript

Here is the php for AJAX where the the INACTIVE data should be displayed.

JavaScript

Here is the link of the image

Advertisement

Answer

Instead of location.reload() you can change p tag class and text inside your success function of ajax . So, if the button has class btn-success remove this class using removeClass() method and add btn-danger class using addClass() method and vice-versa.

Demo Code :

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement