I have declared an Action as follow:
public ActionResult EditComment(int id)
{
try
{
var comment = commentRepository.GetItem(id);
return PartialView("Comment",comment);
}
catch
{
return Content("Error!");
}
}
And this is what I have in some view:
.....
<%:Html.ActionLink(GlobalText.Edit,"#", null, new { @class="EditLink",id=item.CommentID})%>
.....
<div id="link">
</div>
<script type="text/javascript">
$(document).ready(function () {
$('.EditLink').click(function () {
var idval = this.id;
$.ajax({
url: "/Articles/EditComment",
data: { id: idval },
success: function (mydata) {
$("#link").empty().append(mydata);
},
type: "POST"
});
return false;
});
});
When I Click on a link with 'EditLink' Class, the application go through running action result, but '$("#link").empty().append(mydata);' of jquery does not work, and i get nothing!
try to change public ActionResult - to PartialResult EditComment(int id)
$(document).ready(function () {
$(".EditLink").each(function(){
$(this).click(function () {
var idval = this.id;
$.ajax({
url: "/Articles/EditComment",
data: { id: idval },
success: function (mydata) {
$("#link").empty().append(mydata);
},
type: "POST"
})
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.