I have a problem in my code. I make a simple form using the checkbox. when the checkbox is clicked, the data will be validated. then if validation is successful then the checkbox will still be checked and window.location will change, if it fails, the checkbox will be unchecked and window.location will change.
$(document).ready(function () {
$(".publish").click(function () {
var data = $(this).attr("data-identity");
if ($(this).attr('checked', true)) {
var url = "/Manager/AdminApprove/";
}
$.ajax({
url: url + data
}).done(function (data) { //refresh after click
$(document).change(function () {
if ($(".publish").prop('checked', true)) { //if data succes validation
var error_succes = "Succes";
}
else {
var error_succes = "Error";
}
window.parent.location = "/Manager/Admin?" + error_succes;
});
});
});
});