title: why doesn't this jQuery code work in IE?
body: <p>The following code is used so when clicking 'enter' when focused in an input field within a form, it disables the standard submit button functionality.  Rather the javascript builds a new form and sends a post request to another page.  I am using this so that I can achieve a "form within a form" functionality.  The input field has its own submit button for which I have similar code to perform the post.</p>
  
  <p>In firefox, this works perfectly; in IE hitting enter does nothing at all.  Here is the code:</p>
  
  <pre><code>//event handler for input field within standard form
  $('#inputfield').bind('keypress', function(e) {
      var code = e.keyCode || e.which;
      if(code==13){
          //suppress default submit functionality
          $('form').submit(function () {
              return false;
          });
  
          //...assemble some data here...
  
          var url_string = "...";
  
          var $form = $("&lt;form method='POST'&gt;").attr("action", url_string);
          $("&lt;input type='hidden' name='body'&gt;").attr("value",body).appendTo($form);
  
          $("&lt;input type='hidden' name='title'&gt;").attr("value",title).appendTo($form);
  
          //...create more form elements here...
  
          $form.appendTo("body");
          $form.submit();
      }
  });
  </code></pre>
  
  <p>Any ideas why this isn't working in IE (I tried in IE 6,7 and 8)?</p>
  
  <p><strong>Update:</strong> just to elaborate on the problem: in firefox, the <code>$form.submit();</code> line at the end causes the jquery generated form to submit and the page to redirect. In IE nothing happens at all.  The keypress <em>does</em> fire in IE, its just that the form doesnt seem to get submitted.</p>