我即时调用一个对话框(点击),而不是先将其设置为var。像这样:
$(".deleteSaved").click(function() {
save_id = $(this).attr('id');
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
});
});
但是当我在ajax成功函数中调用$(this).dialog("close");时,我收到以下错误:
Uncaught cannot call methods on dialog prior to initialization; attempted to call method 'close'
在" cancel"按钮$(this).dialog("close");工作得很好。
如何在ajax成功通话中使用close函数?