title: Reload page with javascript or Symfony?
body: <p>After a form is submitted, a modal is closed and a success notification is sent.
  However, the newly submitted data doesn't appear as captured, because the page doesn't refresh.  (Can't get it to refresh with either PHP or javascript)</p>
  
  <p>In this situation, I'd assume a javascript refresh would be ideal - or would a Symfony redirect be more appropriate?</p>
  
  <p>Success code in php/symfony:</p>
  
  <pre><code>$passthroughVars = array(
      'closeModal'=&gt; 1,
      'jsContent' =&gt; 'custom_widget'
  );
  
  $passthroughVars['widgetHtml'] = $this-&gt;renderView('WidgetBundle:Widget:widget.html.php', array(
      'widget' =&gt; $widget,
  ));
  $passthroughVars['widgetId'] = $widget-&gt;getId();
  $passthroughVars['flashes'] = $this-&gt;getFlashContent();
  
  $response = new JsonResponse($passthroughVars);
  $response-&gt;headers-&gt;set('Content-Length', strlen($response-&gt;getContent()));
  
  return $response;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>Widgety.widgetOnLoad = function (container, response) {
      if (response) {
          if (response.upWidgetCount) {
              var count = parseInt(mQuery('#WidgetCount').html());
              count = (response.upWidgetCount &gt; 0) ? count + 1 : count - 1;
  
              mQuery('#WidgetCount').html(count);
          }
  
          if (response.widgetHtml &amp;&amp; response.widgetId) {
              var el = '#Widget' + response.widgetId;
              if (mQuery(el).length) {
                  mQuery(el).replaceWith(response.widgetHtml);
              } else {
                  mQuery('#widget-container .widget').prepend(response.widgetHtml);
              }
  
              mQuery(el + " *[data-toggle='ajaxmodal']").off('click.ajaxmodal');
              mQuery(el + " *[data-toggle='ajaxmodal']").on('click.ajaxmodal', function (event) {
                  event.preventDefault();
  
                  Widgety.ajaxifyModal(this, event);
              });
  
              mQuery(el + " *[data-toggle='confirmation']").off('click.confirmation');
              mQuery(el + " *[data-toggle='confirmation']").on('click.confirmation', function (event) {
                  event.preventDefault();
                  WidgetyVars.ignoreIconSpin = true;
                  return Widgety.showConfirmation(this);
              });
          }
  
          if (response.deleted &amp;&amp; response.widgetId) {
              var el = '#Widget' + response.widgetId;
              if (mQuery(el).length) {
                  mQuery(el).remove();
              }
          }
      }
  };
  </code></pre>
  
  <p>In the javascript, I've tried adding <code>document.location.reload(true)</code> yet the content did not refresh.
  Likewise, with a PHP redirect, the modal refuses to close, even while passing     <code>closeModal = 1</code>.</p>
  
  <p>Code:</p>
  
  <pre><code>return $this-&gt;redirect($this-&gt;generateUrl('widget_page',
  array(
      'passthroughVars' =&gt; array(
          'closeModal'    =&gt; 1,
      ),
      'widgetAction' =&gt; 'overview',
      'widgetId' =&gt; $widget-&gt;-&gt;getId()
      )
  ));
  </code></pre>