我工作的jQuery AJAX調用,但我想檢查請求的結果,所以我說jQuery的努力來處理Ajax故障和sucess不工作
success: function(data) {
if(data.status == 'success'){
alert("Thank you for subscribing!");
}else if(data.status == 'error'){
alert("Error on query!");
}
}
但這不是工作,使我的整體功能停止even.so在這裏工作是整個功能,可有人告訴我,我是什麼做wrong`
function addGoal() {
var description = $('.description').val();
var measure = $('.measure').val();
if( description.trim() && measure.trim() ){
if(window.confirm("Are you sure? You can't edit or remove goal(s) you have added here.")==true) {
$.ajax({
url: '${g.createLink(controller:'review', action:'saveGoal', params:[id: params.id] )}',
data: {
"description": description,
"measure": measure
},
success: function(data) {
if(data.status == 'success'){
alert("Thank you for subscribing!");
}else if(data.status == 'error'){
alert("Error on query!");
}
}
type: 'POST'
});
}
}else {
showErrorMessage("Description and Measure fields cant be empty");
}
}`
當我刪除它的作品,因爲我預期它to.And如果它的事項使用Grails
很成功
你錯過了'''的'}在'success'塊 –