Here is my if
statement:
AND a Fiddle: http://jsfiddle.net/setMa/
$('#addamenity').click(function () {
var id = $('.editblock').find('#id').val();
var amenity = $("#amenity").val();
var dataString = {
id: id,
amenity: amenity
};
console.log(dataString);
if (amenity != '' || id != '') {
$.ajax({
type: "POST",
url: "classes/add_amenities.php",
data: dataString,
cache: false,
async: false,
success: function (html) {
$('.editunitamenities').load('classes/display_amenities.php?id=' + id);
}
});
} else {
alert('You must SAVE your changes to the new unit before adding amenities.');
}
});
Now, my console log clearly shows an id of ""
what gives? If I take the ||
off the if
or leave the text field blank it works just fine.