why jquery and ajax unobtrusive send multiple Post to server

309 Views Asked by At

I have a little problem with jquery and Microsoft Unobtrusive libraries.

I created a View with many PartialViews, and in one Partial a button displays a popUp, when I do submit in the popUp, it sends multiple POST to the server.

This is my code:

The main View

@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/CerrarMensaje.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-1.10.1.min.js"></script>
<script>  
    //... other scripts
</script>

<!--contenido-->
<div class="especialistas_contenido">
    <div class="intro_busqueda">
        <div class="columna_1">
            //... other HTML fields
            @{ Html.RenderAction("Partial1", "Controller", new { area = "area" }); }
            @{ Html.RenderAction("Partial2", "Controller", new { area = "area" }); }
        </div>
        <div class="columna_2_media ">
            @{ Html.RenderAction("Index", "Sede", new { area = "Institutos" }); }
        </div>
    </div>
</div>

The Popup's PartialView

<script>
    //... Other script
</script>

<ul class="perfil_datos">
    @using (Ajax.BeginForm("Action", "Controller", new { area = "area" }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "dialogSedes" }, new { id = "formModSede" }))
    {
        //... HTML fields
    }
</ul>
1

There are 1 best solutions below

1
On

It might be because you are adding the same scripts twice.

You are adding jquery through @Scripts.Render("~/bundles/jquery") and then again just below it.

Make sure all the scripts are only getting added once.

Also go through your bundles and make sure there aren't any duplicates