代码如下:
@model aa.Models.DeptTbl
@using (Ajax.BeginForm("AddDept", "Dept", new AjaxOptions
{
OnSuccess = "CommentSuccess",OnBegin = "CommentBegin" } , new { id = "CommentForm" } ) )
{
<div >
<fieldset >
<legend > </legend >
<div style = " width:600px;display:block;height:30px; " >
<div id = ' rating - select ' style = " width:300px; " >
@Html.LabelFor(model => model.DeptId)
@Html.TextBoxFor(model => model.DeptId, new { style = " width:500px; " })
@Html.LabelFor(model => model.DeptType)
@Html.TextBoxFor(model => model.DeptType, new { style = " width:500px; " })
@Html.LabelFor(model => model.DeptName)
@Html.TextBoxFor(model => model.DeptName, new { style = " width:500px; " })
</div >
<div class = " error " >
</div >
</div >
<p style = " width:600px;display:block; " >
ddd
</p >
<div class = " error " >
</div >
<p style = " width:600px;display:block; " >
</p >
<div class = " error " >
</div >
<p style = " text-align:center;width:600px; " >
<input id = "ComentSubmit" type = "submit" value = " 保存 " />
</p >
<p style = " text-align:center;display:none; " id = "CommentLoad" > <img src = " /Images/blue-loading.gif " alt = " 正在保存…… " /> </p >
<p style = " text-align:center;color:Red; " id = "CommentMsg" > </p >
</fieldset >
</div >
}
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")>"></script>
<script src="/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type = " text/javascript ">
function CommentBegin() {
alter("开始");
$("#CommentForm input").attr ( "readonly" , true ) ;
$("#CommentSubmit") . attr ( " disabled " , "disabled" ) ;
$("#CommentMsg").html ("" ) ;
alter("aa");
}
function CommentSuccess(e)
{
alter("成功");
}
</script> 控制器:
[HttpPost]
public JsonResult AddDept ( aa.Models.DeptTbl d)
{
//先测试,暂时OK
return Json(new { Success = true, Message = " 添加部门信息OK! " }, JsonRequestBehavior.DenyGet);
}
问题: 到我提交的时候并没有执行CommentBegin,执行成功之后也没有弹出成功,但是为提示文件下载
下载的文件用记事本打开是返回的JsonResult!!请问怎么解决
@model aa.Models.DeptTbl
@using (Ajax.BeginForm("AddDept", "Dept", new AjaxOptions
{
OnSuccess = "CommentSuccess",OnBegin = "CommentBegin" } , new { id = "CommentForm" } ) )
{
<div >
<fieldset >
<legend > </legend >
<div style = " width:600px;display:block;height:30px; " >
<div id = ' rating - select ' style = " width:300px; " >
@Html.LabelFor(model => model.DeptId)
@Html.TextBoxFor(model => model.DeptId, new { style = " width:500px; " })
@Html.LabelFor(model => model.DeptType)
@Html.TextBoxFor(model => model.DeptType, new { style = " width:500px; " })
@Html.LabelFor(model => model.DeptName)
@Html.TextBoxFor(model => model.DeptName, new { style = " width:500px; " })
</div >
<div class = " error " >
</div >
</div >
<p style = " width:600px;display:block; " >
ddd
</p >
<div class = " error " >
</div >
<p style = " width:600px;display:block; " >
</p >
<div class = " error " >
</div >
<p style = " text-align:center;width:600px; " >
<input id = "ComentSubmit" type = "submit" value = " 保存 " />
</p >
<p style = " text-align:center;display:none; " id = "CommentLoad" > <img src = " /Images/blue-loading.gif " alt = " 正在保存…… " /> </p >
<p style = " text-align:center;color:Red; " id = "CommentMsg" > </p >
</fieldset >
</div >
}
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")>"></script>
<script src="/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type = " text/javascript ">
function CommentBegin() {
alter("开始");
$("#CommentForm input").attr ( "readonly" , true ) ;
$("#CommentSubmit") . attr ( " disabled " , "disabled" ) ;
$("#CommentMsg").html ("" ) ;
alter("aa");
}
function CommentSuccess(e)
{
alter("成功");
}
</script> 控制器:
[HttpPost]
public JsonResult AddDept ( aa.Models.DeptTbl d)
{
//先测试,暂时OK
return Json(new { Success = true, Message = " 添加部门信息OK! " }, JsonRequestBehavior.DenyGet);
}
问题: 到我提交的时候并没有执行CommentBegin,执行成功之后也没有弹出成功,但是为提示文件下载
下载的文件用记事本打开是返回的JsonResult!!请问怎么解决
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货