On ajax success I have to hide a class and show the different class.
Suppose I have “foo” and “bar” two classes. Now it has “foo” class when my ajax returns success then I want to show the “bar” class.
$.ajax({
type:'POST',
url:"/test/",
data:{"test_data": my_data},
success:function(data) {
},
dataType:"json"
// here I want to hide the "foo" class and show the "bar" class.
});
Actually “foo” and “bar” is a class of button. when i click button having “foo” class it should hide and button having “bar” class should be shown. and vice versa
You didn’t mentiond on which element you want to apply this. Anyway this will give you an idea:
This will apply the changes after the
ajax requesthas completed (regardless if it fails or not). If you just want to apply the changes on success just pack that lines into yoursuccess handler.