I need a second pair of eyes on this as cannot see why it’s returning:
$("#message").removeClass().addClass(data.error === true ? "error" : "success").html(data.msg).show is not a function
My code is as follows:
$.ajax({
type : 'POST',
url : 'postcode-lookup.php',
dataType : 'json',
data: {
postcode : $('#postcode').val()
},
success : function(data){
$('#waiting').hide(500);
$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success').text(data.msg).show(500);
if (data.error === true)
$('#restricted_locator').show(500);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#waiting').hide(500);
$('#message').removeClass().addClass('error').text('There was an error.').show(500);
$('#restricted_locator').show(500);
}
});
If
data.msgisundefinedthen$("#message")....html(data.msg)will return a string and calling ashowmethod on string will give you that error.Demo