我有一个函数可以将一些日期发送到另一个将其输入db的页面。当在第二页上完成输入时,我发出了一个回复:
echo 'phoneAdded';
我似乎得到了回复,但我无法触发基于它的其他功能......
$.ajax({
type: 'POST',
url: '/addNewPhoneNumber.ajax',
data: {
'bid' : bid,
'nbr' : newNum
},
dataType : 'json',
success: function (response) {
if(response.status === 'phoneAdded') {
// phone stored in db
alert('Successfully added.');
});
} else if(response.status === 'phoneExists') {
// phone already in db
alert('Sorry, this phone is already in use.');
}
}
});
我错过了什么?
答案 0 :(得分:0)
警报后您还有一个});
。格式如下:
$.ajax({
type: 'POST',
url: '/addNewPhoneNumber.ajax',
data: {
'bid': bid,
'nbr': newNum
},
dataType: 'json',
success: function (response) {
if (response.status === 'phoneAdded') {
// phone stored in db
alert('Successfully added.');
} else if (response.status === 'phoneExists') {
// phone already in db
alert('Sorry, this phone is already in use.');
}
}
});