我有一个简单的功能,显示成功的成功div:
anysuccess("The user has been removed from this list.");
这会在页面顶部显示一个DIV。
我想在AJAX呼叫之后调用它,例如
$.ajax({
type: "POST",
url: '/ajax/actions/remove_user_from_list.php?sei=' + sei + '&sui=' + sui,
success: function (data) {
if(data==='ok'){
anysuccess("The user has been removed from this list.");
} else {
$('#errorBoxEvent').html('Houston, we have a problem!');
}
}
}); // End .ajax
当我尝试这个时,我得到anysuccess is not defined
,我猜这是一个范围问题?
有没有办法在ajax响应中调用函数?或者解决方法?
答案 0 :(得分:0)
工作正常
当您检查成功条件时,它可能不会转到“if”部分
if(data){
anysuccess("The user has been removed from this list.");
} else {
$('#errorBoxEvent').html('Houston, we have a problem!');
}