开发者

Ajax.BeginForm returns full page

开发者 https://www.devze.com 2023-02-17 18:35 出处:网络
I want to use the Ajax.BeginForm, without updating any element, only call the callback javascript function.

I want to use the Ajax.BeginForm, without updating any element, only call the callback javascript function.

I've attached js libraries

<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive开发者_运维技巧.min.js")" type="text/javascript"></script>

I use:

@using (Ajax.BeginForm(new AjaxOptions {OnComplete = "AddPostComplete"}))
{
//some code
}

and

<script type="text/javascript">
  $('#asdf').click(function () {
        //some code
    });
</script>

the js function isn't used, and the page return full view.


With unobtrusive javascript enabled you will also need to include jquery.unobtrusive-ajax.min.js

0

精彩评论

暂无评论...
验证码 换一张
取 消