Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax.BeginForm returns full page

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.

like image 814
Sarzniak Avatar asked Mar 17 '11 23:03

Sarzniak


1 Answers

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

like image 86
Lukáš Novotný Avatar answered Nov 15 '22 12:11

Lukáš Novotný