George George - 6 months ago 14x
Javascript Question

toggleClass not working in ajax

Hello Im new on stackoverflow, i have this GET method its work fine i mean i get a respone from server but i toggleClass is not working i dont know why ?

this is my code:

$("#form1").on("click", function() {
var user = $("#form1 input.user").val();
url: "admin.php?user=" + user,
type: "GET",
beforeSend: function() {},
success: function(res) {
$("#results .name").toggleClass('.active');


you dont need a dot just remove it from your code change

$("#results .name").toggleClass('.active');


$("#results .name").toggleClass('active');