我需要第二双眼睛,因为看不出它为什么会回来:
$("#message").removeClass().addClass(data.error === true ? "error" : "success").html(data.msg).show is not a function
我的代码如下:
$.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);
}
});
答案 0 :(得分:0)
如果data.msg
为undefined
,则$("#message")....html(data.msg)
将返回一个字符串,并在字符串上调用show
方法将为您提供该错误。
<强> Demo 强>