title: mvc ajax refresh div method controller json
body: <p>I have a method in the controller that return a ViewBag with Json.</p>
  
  <pre><code> public JsonResult FilterCheck(int id, int[] mycheck, string idprot)
      {
      ViewBag.Utenti = this.GetDbContext().utente.Include(s =&gt; s.cod_servizio_utente).Where(x =&gt; x.cod_servizio_utente.Select(l =&gt; l.id).Contains(5)).ToList();
  
  return Json(ViewBag.Utenti, JsonRequestBehavior.AllowGet);
  
      }
  </code></pre>
  
  <p>In the view I have this script function ajax, if this function have "success" i would refresh a div that include a foreach on the viebag.Utenti:</p>
  
  <pre><code> $.ajax({ 
                  type: "POST",
                  url: "@Url.Action("FilterCheck","Operatore")",
                  datatype: "json",
                  traditional: true,
                  data: { 'mycheck': mycheck, 'idprot': idprot, 'id': '@Model.id' },
                  success: function(data) {
                      var html = $(data).filter('#external-events').html();
                      $('#external-events').html(data);
                  }
              });
  
  &lt;div id='external-events'&gt;
  
                @foreach (HAnnoZero.Repositories.utente item in ViewBag.Utenti)
          {
              &lt;div class='col-lg-3'&gt;&lt;div class='external-event'&gt;@item.id- @item.cognome @item.nome&lt;/div&gt;&lt;/div&gt;    
          }    &lt;/div&gt;
  </code></pre>
  
  <p>But dont work. How can do for refresh the foreach inside div id "external events"?Who could help me?</p>