本文由我司收集整编,推荐下载,如有疑问,请与我司联系如何发布ASP。使用JavaScript而不是提交按钮的NET MVC Ajax表
I have a simple form created using Ajax.BeginForm:
 我有一个使用ajax创建的简单表单。
 % using (Ajax.BeginForm(“Update”, “Description”, new { id = Model.Id }, new AjaxOptions UpdateTargetId = “DescriptionDiv”, HttpMethod = “post” },new {id =‘AjaxForm’ })) {% Description: %= Html.TextBox(“Description”, Model.Description) % br /  input type=“submit” value=“save” /  % }%  The controller is wired up and returns a partial view that updates the DescriptionDiv. And it all works neatly.
 连接控制器并返回更新DescriptionDiv的部分视图。这一切都很巧妙。
  Now I would like to be able to submit this form without having the submit button (via a clik on a link or on an image or whatever). Unfortunately this little jQuery snippet does not do the job:
 现在,我希望能够提交这个表单,而不需要提交按钮(通过链接或图像的剪辑)。不幸的是,这个小小的jQuery代码片段并没有起到作用:如何下载javascript
 $(‘form#AjaxForm’).submit(); It does submit the form, but does (I suppose not surprisingly) a regular post-back and not an Ajax one.
 它确实提交了表单,但是(我想这并不奇怪)它是一个常规的回发,而不是Ajax。  For the sake of simplicity the above jQuery is wired up like this:
 为了简单起见,上面的jQuery是这样连接的:
    a href=“#” submit /a  The form’s onsubmit is using the Sys.Mvc.AsyncForm.handleSubmit() but the jQuery submit seems to be bypassing this.
 表单的onsubmit使用的是Sys.Mvc.AsyncForm.handleSubmit(),但是jQuery submit 似乎绕过了这个问题。
  PS. I am looking for a solution in this particular approach. I know how to achieve the

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。