我有一个使用 jquery 发布到服务器的部分视图。该帖子正在运行。但是,返回时,我返回的是带有空白模型(新模型)的 partialviewresult,但返回的 HTML 仍然包含以前发布的数据。关于清除退货数据的任何想法?
$("#btnSend").click(function (e) {
e.preventDefault();
if($('#frmCompose').valid()) {
$.ajax({
type: "POST",
url: '@Url.Action("PartialCompose", "Message")',
dataType: "html",
data: $('#frmCompose').serialize(),
success: function (result) {
$("#divTab2").html(result);
},
error: function (xhr, s, e) {
alert('Error');
alert(xhr.responseText);
}
});
}
});
这是行动:
[SessionExpireFilterAttribute]
[HttpPost] // POST: /message/partialcompose
public PartialViewResult PartialCompose(_MessageExt model)
{
_MessageExtDAL __DAL = new _MessageExtDAL(base.LoginTimeZoneMin);
try
{
model.MessageId = 0;
model.AccountId = base.LoginUser.AccountId;
model.EditBy = base.LoginUser.UserId;
__DAL.Send(model, Config.SQLConn);
}
catch (Exception ex)
{
base.Prompt = ex.Message;
}
finally
{
__DAL = null;
}
return PartialView(new _MessageExt());
}