I am trying to create a form for submitting resume.
I need the candidate name, email , resume cover and the resume(file).
var candidateName = $('#candidateName').val();
var candidateEmail = $('#candidateEmail').val();
var candidateMessage = $('#candidateMessage').val();
var file_data = $('#candidateResume').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
form_data.append('name', candidateName);
form_data.append('id', candidateEmail);
form_data.append('msg', candidateMessage);
console.log(form_data);
$.ajax({
    url: "cvForm.php",
    type: "POST",
    data: {candata: form_data},
    success : function(data){
        console.log(data);
    },
    contentType: false,
    processData: false
});
nothing is being returned in my cvForm.php file when I
var_dump($_POST) or
var_dump($_FILES)
when I
var_dump($_POST['candata']) - it says undefined index
The HTML
<form id="cvSubmit" class="mui-form">
                <div>
                    <span class="form-success-msg" id="cv-form-success-msg">
                        Thanks for reaching out to us. We will get back to you shortly.
                    </span>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="mui-textfield mui-textfield--float-label">
                            <input type="text" id="candidateName" class="mui--is-empty mui--is-untouched mui--is-pristine">
                            <label>Name<span class="red-text">*</span></label>
                            <span class="error" id="cv-name-error">Please enter your name</span>
                        </div>
                        <div class="mui-textfield mui-textfield--float-label">
                            <input type="email" id="candidateEmail" class="mui--is-empty mui--is-untouched mui--is-pristine">
                            <label>Email<span class="red-text">*</span></label>
                            <span class="error" id="cv-email-error">Oops!! Looks like its an incorrect email id. Try again</span>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 file-attachment-wrapper">
                                <input class="file-addach" type="file" id="candidateResume">
                                <span>We accept .DOCX,.Doc,pdf,.Txt upto 2 MB.</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="mui-textfield mui-textfield--float-label">
                            <label>Message<span class="red-text">*</span></label><br><br>
                            <textarea id="candidateMessage" rows="5" class="mui--is-empty mui--is-untouched mui--is-pristine"></textarea>
                            <span class="error" id="cv-message-error">That's not very clear...could you rephrase</span>
                        </div>
                        <button type="button" class="mui-btn mui-btn--raised red-btn" onclick="cvSubmit()"> SEND </button>
                    </div>
                </div>
            </form>
Please help. I see this is a common question but none of the solution seems to work for me. Some code refreshes the page, which I don't want to happen.
 
     
     
    