Reload a partial view from JQuery or JavaScript

2

This time I find a doubt that looking in several forums I have not managed to solve, I have a list of notifications, which I post in a partial view, then I invoke this view in a layout. up there all right.

Then I have a script that when clicking on any notification I change its status to seen, if I reload the page it does not appear, but what I want is that when I click just recharge the partial view or remove me the item on my list. I only found the event reload() but it does not work for what I'm looking for, try calling the view again if the ajax is completed but it did not work either.

Part of the layout where I invoke the partial view

    <ul id="alerta1" class="dropdown-menu alert-dropdown">
        @Html.Action("Not", "EntrevistaIdioma")
       <li><a href="" style="text-align:center;">Ver mas...</a></li>
    </ul> 

My partial view

@foreach (var item in Model)
 {

    <li id="btnAlerta" class="alerta btn btn-default">
      @Html.DisplayFor(modelItem => item.nombreCand) @Html.DisplayFor(modelItem => item.apellidoCnad)
    </li>
    <input id="candidato" [email protected] type="hidden">
 }

My script

<script>

$(function () {
    $("#btnAlerta").click(function () {

        var url="@Url.Action("Visto","EntrevistaIdioma")";
        var id= $("#candidato").val();
        var data = { id: id };
        location.reload();
        $.post(url, data).done(function (data) {

        });
    });
});

    
asked by Sara 28.06.2017 в 20:09
source

1 answer

2
@foreach (var item in Model) {

<li id="btnAlerta" class="alerta btn btn-default @item.EntrevistaIdiomaID">
  @Html.DisplayFor(modelItem => item.nombreCand) @Html.DisplayFor(modelItem => item.apellidoCnad)
</li>
<input id="candidato" [email protected] type="hidden"> }

above we put the id in the class of the label li and now ... '

 $(function () {
$("#btnAlerta").click(function () {

    var url="@Url.Action("Visto","EntrevistaIdioma")";
    var id= $("#candidato").val();
    var data = { id: id };
    $.post(url, data).done(function (data) {$("[email protected]").css(display:'none');
    });});});

with which as you said to the partner because you hide the specified notification with the property css display none after the donation of the data and the request

    
answered by 28.06.2017 / 20:47
source