why have you placed your alert
outside the if condition.
try replacing the success function to
success: function (data) {
if(data == 1) {
alert("ok")
} else {
alert("no ok")
}
}
8
solved Why is AJAX request response not matching the desired output? [closed]