我想做的事:
在页面加载时自动弹出一个 jquery 对话框,填写一些数据,将其发布到一个操作并关闭对话框(无论操作是否成功)。
在应该出现弹出窗口的视图中,我有以下内容:
<script type="text/javascript">
$(function () {
$('#PopUpDialog').dialog(
{
modal: true,
open: function ()
{
$(this).load('@Url.Action("Subscription", "PopUp")');
},
closeOnEscape: false
}
);
$('.ui-dialog-titlebar').hide();
$('#closeId').live('click',function () {
$('#PopUpDialog').dialog('close');
return false;
}
);
$('#SubscriptionForm').submit(function () {
$("#PopUpDialog").dialog("close");
$.ajax({
url: encodeURI('@Url.Action("Subscription", "PopUp")' ),
type: this.method,
data: $(this).serialize()
})
return fase;
}
);
});
</script>
订阅视图具有以下内容:
@using (Html.BeginForm( new { id = "SubscriptionForm" }))
{
@Html.ActionLink(Deals.Views.PopUp.SubscriptionResources.AlreadySubscribed, "", null, new { id = "closeId" })
<br />
<br />
@Deals.Views.PopUp.SubscriptionResources.FillEmail
@Html.TextBoxFor(m => Model.Email)
<input type="submit" id="subscribeId" value="@Deals.Views.PopUp.SubscriptionResources.IWantToSubscribe" />
<br />
}
效果很好。
POST 动作定义如下:
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Subscription(FormCollection formValues)
//public void Subscription(FormCollection formValues)
{
Deals.ViewModels.PopUpSubscriptionVM VM = new ViewModels.PopUpSubscriptionVM();
TryUpdateModel(VM);
if (!String.IsNullOrEmpty(VM.Email))
{
//do the update to the dbms
}
return Json(new { success = true });
}
问题是,在发回后,我得到一个显示成功消息的空白屏幕,这是我不想要的!我究竟做错了什么?