title: Target ajaxSubmit to a popup window
body: <p>I have a form that needs to be validated before submit, POST to a popup window, then the form needs to be reset afterwards.</p>
  
  <p>I know the <code>target="newWindowName"</code> and <code>onsubmit="window.open('','newWindowName','')"</code> form attributes work, but this doesn't let me do anything after submit.</p>
  
  <p>I know I can use <code>$('form').ajaxSubmit()</code> to specify an after-submit function, but it doesn't seem to let me open a new window.</p>
  
  <p>How can I do all these things at once? </p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form id="myForm" target="newWindow" autocomplete="on" action="/myUrl" method="post"&gt;
  </code></pre>
  
  <p>This is my javascript:</p>
  
  <pre><code>$('#myForm').submit(function(e) { 
      e.preventDefault();
      if ($('#myForm').valid()) {
          var options = {
              target: '',
              beforeSubmit: function () {
                  this.target = "newWindow"; 
                  window.open("", "newWindow", "width=500,height=450");
              },
              success: function () {
                  hideForm();
                  $('#myForm').resetForm();
              }
          };
  
          $(this).ajaxSubmit(options);
      }
      return false;
  }
  </code></pre>