hello, I have a button that depending on a class value should send different values to the POST however what ever happens it is only running one condition, whatever I do I can only get it to send the POST the method=add data.
This is my code
$("a.navlink").click(function (ev) {
$(this).removeClass("active");
var url = $(this).attr("href")
ev.preventDefault();
if($('a.navlink:not(.active)')) {
$.ajax ({
url: url,
type: "POST",
data: "method=add",
success : function (html) {
$('#accordion').accordion('destroy');
$("#accordion").append(html);
$('#accordion').accordion({
active: 0,
header:'h2.Blog'
});
//alert(accordion())
}
});
}
if ($(this).hasClass("active")) {
// $(this).addClass('active')
$.ajax ({
url: url,
type: "POST",
data: "method=delete",
success : function (html) {
alert("hello")
$(this).removeClass('active')
//alert(accordion())
}
});
}
});
Basically what I need is, if when the button is clicked it gets a class called active added to it and the ajax runs, when it is clicked again, the class needs to be removed and the ajax run, is this possible?