title: jqgrid issue to refresh at close dialog window
body: <p>I have a grid (jqGrid) I get the data using an ajax call, when clicking on the record it opens a dialog window (jquery ui) that contains the details of the selected record. After doing an update on that record just by another ajax call, close the modal window and try to refresh the grid by calling back to an ajax function to update the grid. However, this causes multiple calls to my server and I do not know why it does, I leave my code to see if somebody can help. </p>
  
  <pre><code>$(document).ready(function () {
      ajaxCallGrid('/myjsp.jsp', 1);
  });
  function ajaxCallGrid (url, op) {
      $.ajax({
          url: url,
          type: "get",
          cache: false,
          beforeSend: function (xhr) {
              xhr.setRequestHeader("Content-type", "application/json; charset=ISO-8859-1");
          },
          dataType: "text json", contentType: "application/json; charset=ISO-8859-1", success: function (obj) {
              if (obj.status == "OK") {
                  if (op == 1) {
                      fillJQGrid(obj.data);
                  }
                  else {
                      $('#list').jqGrid('clearGridData');
                      $('#list').jqGrid('setGridParam',{data: obj.problemas});
                      $('#list').trigger('reloadGrid');
                  }
              }
              else alert("error--&gt;" + url + " error--&gt;" + obj.statustext);
          },
          error: function (jqXHR, textStatus, errorThrown) {
              alert("error-&gt; " + errorThrown + " - " + textStatus + " -" + jqXHR.responseText);
          }
      });
  }
  function fillJQGrid (obj) {
      var grid = $("#list");
      grid.jqGrid({
          colModel: [{name:'XXX', index:'XXX', width:50, align:"center"},{name:'YYY', index:'YYY', width:70, hidden: true}], colNames:['X', 'Y'], pager: '#pager', datatype: "local", data: obj, rowNum: 2, viewrecords: true, caption: "DATA GRID", height: "auto", width: 1000, ignoreCase:
          true, onSelectRow: function (ids) {
              var x = $('#list').jqGrid('getRowData', ids);
              var variable = x.XXX;
              var url = '/myjsp2.jsp?variable=' + variable;
              iframe = $('&lt;iframe frameborder="0" marginwidth="0" marginheight="0"&gt;&lt;/iframe&gt;');
              dialog = $("&lt;div&gt;&lt;/div&gt;").append(iframe).appendTo("body").dialog( {
                  autoOpen: false, modal: true, resizable: false, width: 1010, height: 610, closeOnEscape: true, close: function () {
                      closeIframe(1);
                      iframe.src = "about:blank";
                  }
              });
              var src = url;
              var title = 'Anything';
              var width = 1010;
              var height = 610;
              iframe.attr({width: + width, height: + height, src: src});
              dialog.dialog("option", "title", title).dialog("open");
          }
      });
      grid.jqGrid('navGrid', '#pager',{edit:false, add:false, del:false});
  }
  function closeIframe (opt) {
      switch (opt) {
          case 1:
          dialog.dialog('close');
          break;
          case 2:
          $('&lt;div&gt;&lt;/div&gt;').dialog( {
              modal: true, title: "MESSAGE", open: function () {
                  var markup = 'CHANFGES OK';
                  $(this).html(markup);
              }, buttons: {
                  ok: function () {
                      $('#list').remove();
                      $(this).dialog("close");
                  }
              }, close: function () {
                  dialog.dialog('destroy').remove();
                  // here is when make many calls to my server....
                  ajaxCallGrid('/myjsp.jsp', 2);
                  /*  NEXT LINE IS BAD !!!! */
                  $(this).dialog("close");
              }
          });
          break;
      }
  }
  </code></pre>
  
  <p>The next code its inside myjsp2, that call closeIframe again:  </p>
  
  <p>window.parent.closeIframe(2);</p>
  
  <p>Thank you very much.</p>