In the view , I have a table that contains data from the database. When I click on edit, a modal contains the edit form appears. When I make the change and I click the save button, the updates is saved in the database and all it works well.
Now I'd like to know how I can display in the view the update was done without refreshing the page.

```
{% for entity in entities %}
<td>{{ entity.id }}</td>
//....
<td> 
  <a href data-toggle="modal" data-target="#myModal-{{ entity.id }}"
       class="btn btn-mint btn-xs btn-icon btn-circle icon-lg fa fa-pencil">
     </a>
</td>

{% endfor %}

```

the ajax request

```
$(document).on('click', ".btn-edit-ajax", function (e) {
    e.preventDefault();
    var $form = $(this).closest('form');
    var action = $form.attr('action');
    var data = $form.serialize();
    var $btn = $('.btn-edit-ajax');

    $btn.prop("disabled", true);

    $.ajax({
        type: 'post',
        dataType: 'json',
        data: data,
        url: action,
        success: function (data) {
            if (data.result == 0) {
                $('.div-errors').replaceWith($(data["view"]));
                $btn.prop("disabled", false);
            }
            else {
                $("#myModal").modal('hide');
                $btn.prop("disabled", false);
            }
        },
        error: function (XHR, status, error) {
            $btn.prop("disabled", false);
            hideLoading();
            console.log(XHR);
            console.log(status);
            console.log(error);
            alert(error);
        }
    });
});

```

Action

```
if ($form->isValid()) {
   $em = $this->getDoctrine()->getManager();
   $em->persist($entity);
   $em->flush();

   $response = new JsonResponse();
   return $response;

}

```