I have a few short questions. I have a form that I am sending via jQuery's Ajax, and it works how I want it to. If I disable JavaScript, the form also sends via server-side, and it works too. When I send the form via Ajax, the form sends and I have a little spinner (add a class with beforeSend), and on success I display a thank you message. Question 1 is, (this may be silly), how does Ajax determine the mail was sent successfully? (I am currently using PHPMailer to send mail from my localhost). 
Or rather, is 'success' just based on being able to send the form data to the processing file? My success message is "thank you, your message has been sent", and I don't want to display this if the message was not actually sent, but Ajax displays it anyway because it was able to interact with the mail processing file. I am sending via the POST method of course, and my success function doesn't take a parameter (I am not expecting data back). My data is just form data using serialize() to package it all together.
My second question is, when I disable JS and the form sends, it uses header() to determine where to go after the mail is sent, and the header() code is in the same mail processing file that .ajax() uses in its URL. Why is it that when .ajax() sends the file it doesn't use header to go to the "thank you" page, but when JS is disabled it uses header() and goes to the thank you page? All the code is in the same file, so does it skip the header() part? Is it because the page simply doesn't reload? This may be silly but I'd just like to know what's going on here. Thanks so much.
EDIT: I should have added the code, my apologies. Here is the ajax call I am making:
$.ajax(' url', {
            type: "POST",
            data: form.serialize(),
            success: function() {
                var formWrapper  = $('.form-wrapper');
                var confirmMessageSection = $("<section class=\"confirm-message\"></section>");
                formWrapper.empty().append(confirmMessageSection);
                confirmMessageSection.html("<p>Thank you! Your message has been sent.</p>").hide().fadeIn(1500);            
            },
            error: function(request, errorType, errorMessage) {
                var formWrapper = $('.form-wrapper');
                var errorMessageSection = $("<section class=\"email-error\"></section>");
                formWrapper.empty().append(errorMessageSection);
                errorMessageSection.html("<p>Sorry, there was an error.</p><p>Request error type: " + request + "</p><p>Error type: " + errorType + "</p><p>Error Message: " + errorMessage + "</p>").hide().fadeIn(1500);  
            },
            timeout:5000,
            beforeSend: function() {
                //add spinner
                $('.form-wrapper').empty().addClass('is-loading');
            },
            complete: function() {
                //remove spinner
                $('.form-wrapper').removeClass('is-loading');
            }
        });
At the top of my processing file I have:
$sentMail = false;
And then it runs through my validation and then at the end:
$sentMail = $mail->Send();
    if(!$sentMail) {
        $errors['mailNotSent'] = true;
    }
     if($sentMail) {
                header('Location: thankyou-nojs.php');
                exit;
   }
}
mail()returnsTRUEorFASLE