我正在调用一个对话框(点击),而不是首先将其设置为var。像这样:无法在ajax成功关闭对话框
$(".deleteSaved").click(function() {
save_id = $(this).attr('id');
div="<div>Are you sure you want to delete this?</div>";
$(div).dialog({
buttons: {
"Delete": function() {
$.ajax ({
url:"util.php",
data:"q=0&f=delete&save_id="+save_id,
success: function(result){
$(this).dialog("close"); //this line is not working
$("#toprow"+save_id).fadeOut();
$("#botrow"+save_id).fadeOut();
}
})
},
"Cancel": function() {
$(this).dialog("close");
}
},
modal: true,
title: 'Delete Saved Signal',
resizable: false
});
});
但是当我打电话$(this).dialog("close");
阿贾克斯成功函数我碰到下面的错误中:
Uncaught cannot call methods on dialog prior to initialization; attempted to call method 'close'
内“cancel
”按钮$(this).dialog("close");
工作得很好。
如何获取关闭函数在ajax成功调用中工作?
这是一个很好的解决方案@robert,我一直在努力工作数小时这个。非常感谢! :) – Anurag