$.post 呼び出し内で要素を .remove() 関数に渡すと、ページからフォームを削除できません。
これが私のコードです:
function cancelUpload(form) {
$( "#closeModal" ).dialog({
resizable: false,
height:200,
modal: true,
buttons: [
{
text: "Yes",
click: function() {
$.post(
"misc/removeMedia.php",
{location: form.location.value},
function(result) {
if(result.split('|')[0] == "Success"){
$(form).remove();
noty({text: result.split('|')[1], type: "information"});
} else {
noty({text: result.split('|')[1], type: "error"});
}
},
"html"
);
$(this).dialog("close");
},
class: "btn btn-success"
},
{
text: "No",
click: function() {
$(this).dialog("close");
},
class: "btn btn-danger"
}
]
});
}
$.post 呼び出しを完全に取り除き、$(form).remove() を配置するだけで機能します。したがって、正しい要素を関数に渡していることがわかります。
jsFiddle サンプル: http://jsfiddle.net/4NDFR/