title: Javascript notification when a file is uploaded
body: <p>The following form works well to upload a file and stays on the same page. So far so good, the file does make it to the server.</p>
  
  <pre><code>= form_tag("imgupload", remote: true, multipart: true, id: 'image_upload_form' ) do
    .field
      = label_tag :image
      = file_field_tag :image
    = submit_tag "Upload Image"
  </code></pre>
  
  <p>How can I get notified in Javascript when the file/form has finished uploading?</p>
  
  <p>I tried the following but it doesn't fire any of the alerts:</p>
  
  <pre><code>$("#image_upload_form").bind("ajax:complete", function(evt, data, status, xhr) {
    alert('Complete!');
  });
  $("#image_upload_form").bind("ajax:success", function(evt, data, status, xhr) {
    alert('Success!');
  });
  $("#image_upload_form").bind("ajax:failure", function(evt, data, status, xhr) {
    alert('Failure!');
  });
  </code></pre>