未经处理的异常,在 Function code 中0x800a1391 - Microsoft JScript 运行时错误: “onBegin”未定义 50
控制器里面的代码:[HttpPost,ActionName("Delete")]publicActionResultDeleteConfirmed(intid){peop...
控制器里面的代码:
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
people people = db.people.Find(id);
db.people.Remove(people);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpPost ]
public ActionResult AjaxDelete(int id)
{
System.Threading.Thread.Sleep(3000);
people people = db.people.Find(id);
db.people.Remove(people);
db.SaveChanges();
return RedirectToAction("Index");
}
index里的代码:
@Ajax.ActionLink("删除", "AjaxDelete", new { id = item.id},
new AjaxOptions(){
Confirm = "确认删除吗?",
LoadingElementId = "loading",
HttpMethod = "POST",
OnBegin ="onBegin",
OnComplete = "OnComplete",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure"
}
function onBegin()
{ $('#loading').show(); }
function OnComplete()
{ $('#loading').hide(); }
function OnSuccess(data)
{
alert("删除成功!");
loading.reload();
}
function OnFailure()
{ alert("删除失败"); } 展开
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
people people = db.people.Find(id);
db.people.Remove(people);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpPost ]
public ActionResult AjaxDelete(int id)
{
System.Threading.Thread.Sleep(3000);
people people = db.people.Find(id);
db.people.Remove(people);
db.SaveChanges();
return RedirectToAction("Index");
}
index里的代码:
@Ajax.ActionLink("删除", "AjaxDelete", new { id = item.id},
new AjaxOptions(){
Confirm = "确认删除吗?",
LoadingElementId = "loading",
HttpMethod = "POST",
OnBegin ="onBegin",
OnComplete = "OnComplete",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure"
}
function onBegin()
{ $('#loading').show(); }
function OnComplete()
{ $('#loading').hide(); }
function OnSuccess(data)
{
alert("删除成功!");
loading.reload();
}
function OnFailure()
{ alert("删除失败"); } 展开
1个回答
展开全部
new AjaxOptions(){
Confirm = "确认删除吗?",
LoadingElementId = "loading",
HttpMethod = "POST",
OnBegin ="onBegin",
OnComplete = "OnComplete",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure"
}
你这里实例了一个 new AjaxOptions() 实例时给OnBegin ="onBegin"了值.
而AjaxOptions这个类中没有OnBegin 这个属性,你可以去AjaxOptions类中定义一下,
Confirm = "确认删除吗?",
LoadingElementId = "loading",
HttpMethod = "POST",
OnBegin ="onBegin",
OnComplete = "OnComplete",
OnSuccess = "OnSuccess",
OnFailure = "OnFailure"
}
你这里实例了一个 new AjaxOptions() 实例时给OnBegin ="onBegin"了值.
而AjaxOptions这个类中没有OnBegin 这个属性,你可以去AjaxOptions类中定义一下,
追问
具体怎么定义呢?
追答
你需要去学习,不是盲目的自己实践
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询