title: jQuery - only fires on second click when changing iframe src
body: <p>I'm trying to change the src of an iframe upon submitting a form.</p>
  
  <p>The iframe src won't change unless I hit the submit button twice.  However, if I just change the input 'type' for my submit button to 'text', it works on the first click - but obviously doesn't submit the form.</p>
  
  <pre><code>&lt;script&gt;
  
  $(document).ready(function() { 
      $("#form1").submit(function() {
              $('#upload_frame').attr('src','upload-test.php');
      });
  });
  
  &lt;/script&gt;
  
  &lt;form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"&gt;
    &lt;input id="file" type="file" name="file" /&gt;
    &lt;input name="Submit" id="submit" type="submit" value="Submit" /&gt;
  &lt;br /&gt;
    &lt;iframe id="upload_frame" name="upload_frame"&gt; &lt;/iframe&gt;
  &lt;/form&gt;
  </code></pre>