Ajax表格未提交

I created a form with a file upload progress bar. I am using ajaxForm to set pre/post actions (using ajaxSubmit did caused the progress bar to disappear after a short time). Once the upload process has ended, I want to generate a new web page and send email by calling “sendEmail.php”. The problem is that I can see to progress file reaching 100% but nothing happens after that. T is stuck on 100%

My script to generate the progress bar:

<script> 
var progress
            $(document).ready(function() {  
            $("#submit").click(function(){
       var form_data = $(this).serialize();
              $("#formmail").ajaxForm({
        type: "POST",
                  url: "sendEmail.php",
        beforeSend: function() {
          $("#progressBar").removeClass("hidden");
          progress = "0%";
          $('.progress-bar').css("width", progress);
                    $('.progress-bar').html(progress);
            },
         uploadProgress: function (event, position, total, percentComplete) {
        progress = percentComplete + "%";
        $('.progress-bar').css("width", progress);
        $('.progress-bar').html(progress);  
            },
            success: function (data){
            console.log(data);
            alert("It's OK!");
            },
            error: function(data){
            console.log(data);
           }
           })
      .submit();
          });
          });

</script>

The php to upload the file, in this case only uploa. I will move the file once it is working.

<?php
    if(isset($_POST) && !empty($_FILES['fileatt']['name'])){
    $tmp = $_FILES['fileatt']['tmp_name'];
?>

What should I add so thati wil see the success message and that url: "sendEmail.php" will be executed?

Your this line looks incorrect

var form_data = $(this).serialize();

here this referring to your submit button, not form

furthermore you should use FormData() instead of serialize() becuase serialize() will work in older browsers that don't support the FormData API for example IE < 10

use this instead:

var formData = new FormData($('form')[0]);

Double check your HTML, it seems that you missed to add "name" attribute for the input field file.

This will not work

<input type="file"/>

This will work

<input type="file" name="file1"/>