title: jQuery submit working after second click only
body: <p>I wrote this code that should submit registration form (PHP) using jQuery and iframe.</p>
  
  <p><strong>Javascript</strong>:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).on('click', '#reg_form_sub', function(event) {
  
          var error_message_lgn = $("#reg_frame").contents().text();
  
          $('#reg_error').text(error_message_lgn);
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>    &lt;iframe name="reg_frame" id="reg_frame" style="display:none;" src="register.php"&gt;&lt;/iframe&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p id="reg_error"&gt;&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="email" name="reg_email" id="reg_form_input" placeholder="Email"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="password" name="reg_pass" id="reg_form_input" placeholder="Password"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="password" name="reg_pass_confirm" id="reg_form_input" placeholder="Confirm password"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" name="reg_submit" id="reg_form_sub" value="Send me a confirmation email"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>It is kind of working, but when I click the button the first time nothing happens. </p>
  
  <p>When I click the second time I get echo from PHP (script submits the form, it creates the account etc, but I get echo only after clicking for the second time).</p>