我有一个 jQuery 脚本,我将在删除该记录后隐藏 div。这是jQuery。
$(document).ready(function () {
$(".deleteComment").click(function ()
{
alert("asd");
var Id = $(this).attr("id");
var url1 = "@Html.Raw(Url.Action("DeleteComment", "Comment", new { id = "idValue" }))";
url1=url1.replace("idValue",Id );
alert(url1);
$.ajax(
{
type: 'post',
url: '/Comment/DeleteComment',
dataType: 'json',
data:
{
'EId' : Id
},
success: function (data)
{
alert ("Hello");
var commentBlock = $(this).closest('div');
commentBlock.hide('slow');
}
});
问题仅在以下代码中:
success: function (data)
{
alert ("Hello");
var commentBlock = $(this).closest('div');
commentBlock.hide('slow');
}
如果我将上面的代码放在脚本的开头,那么它可以正常工作。如果我成功了,那么它就会失败。