.live(submit) and ajax

.live(submit) and ajax

When I set up a form that includes a file upload requester and do a normal form submit all the form elements are received by the server side PHP script just fine. When I try to apply this snippet below to post the same form elements via AJAX then the actual submit button and file input are missing...

  1. $("#viewtree form.dialog").live("submit", function() {
  2.   var $form = $(this);
  3.   $.post(
  4.     $form.attr("action"),
  5.     $form.serialize(),
  6.     function(data, status, xhr) {
  7.      $form.closest("dd").html(data);});
  8.   return false;
  9. });
Even using just .submit() instead of .live(submit) makes no difference, neither does v1.4.2 or v1.3.2. I've seen a suggestion to use live(click) and disable submit with .1.4.2 so this almost works...
  1. $("#viewtree form").live("submit", function() { return false; });
  2. $("#viewtree form input.button").live("click", function() {
  3.   var $form = $(this).closest("form");
  4.   var file = $form.find('input[type="file"]')[0];
  5.   var f = $form.serialize() + "&" +$(this).attr("name") + "=" + $(this).attr("value");
  6.   $.post($form.attr("action"), f, function(data) {
  7.     $form.closest("dd").html(data);});
  8.   return false;
  9. });
But I am still missing any input[type=file] info. Would anyone have a general solution for using .live(submit) in an AJAX context or at least how could I assemble and serialize input[type=file] selector settings when using enctype="multipart/form-data" ?