Problem I have.... I have listener script in php that does this:
if ($count != 1) {echo 'no';} else { echo "yes";}
So it echoes "yes" or "no" depending if task was success or not and on my page I have this:
jConfirm('Are you sure you want to delete this publisher?', 'Delete publisher', function (r) {
if (r) $.post('includes/publishers/delete-publisher.php?publisherid=' + publisherid,
function(data) {
if (data == 'no') {
$.jGrowl('Error - PUBLISHER WAS ALREDY DELETED !');
alert("Data Loaded: " + data);
} else {
$(element).parents('tr').remove();
$.jGrowl('Publisher deleted');
alert("Data Loaded: " + data);
}
});
});
And the problem is that ALTHOUGH delete-publisher.php echoes "no" (I see it echoed in alert box) - JQuery is always processing this as if response was "yes" !? Am I missing something obvious ?
Likely there's some whitespace in your response. Try using this instead:
if ($.trim(data) == 'no') {