问题描述
3 preVIEW升级我的ASP MVC 3 Beta版后,我看到奇怪的行为在我的Ajax表单。
After upgrading my ASP MVC from 3 Preview to 3 Beta I see strange behaviour in my Ajax forms.
@using(Ajax.BeginForm("New", new AjaxOptions() {OnSuccess = "onAjaxSuccess", OnFailure = "onAjaxFailure", OnBegin = "onAjaxBegin", HttpMethod = "Post"})) {}
<form action="/Order/New" data-ajax="true" data-ajax-begin="onAjaxBegin" data-ajax-failure="onAjaxFailure" data-ajax-method="Post" data-ajax-success="onAjaxSuccess" method="post"></form>
我下了警报
我的函数内部 onAjaxBegin
,它是beeing发射两次,每次我点击我的提交按钮。
I have placed an alert
inside my function onAjaxBegin
and it is beeing fired twice, each time i click on my submit button.
没有其他人看到这种行为?我升级后没有改变在code什么,它在升级之前完美。
Anyone else seen this behaviour? I have not changed anything in the code after upgrading, and it worked perfectly before the upgrade.
推荐答案
看生成的HTML。 有一个不引人注目的基于jQuery的Ajax和所有阿贾克斯佣工的新支持现在使用jQuery。也许有留下MS阿贾克斯的东西这会导致两个人通话。确保你从页面中移除MSAjax脚本所有的包裹。也是为什么使用 Ajax.BeginForm
时,你可以简单地使用 Html.BeginForm
与jQuery的不显眼?
Look at the generated HTML. In ASP.NET MVC 3 Beta there's new support for unobtrusive jquery based ajax and all the Ajax helpers use jquery now. Maybe there's something left with MS Ajax which causes the double call. Make sure you remove all the inclusions of MSAjax scripts from the page. Also why using Ajax.BeginForm
when you could simply use Html.BeginForm
with unobtrusive jquery?
这篇关于形成了从ASP MVC 3 preVIEW更新到测试版后,提交两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!