I attached, below, the simplified version of my php. I have a from with multiple input field + upload file option.
When the form is submitted the upload bar fires up and when it reaches 100% I see the “success” alert and then the “complete” alert. (twice???) However neither the form “action=sendEmail.php” is triggered not the “url: sendEmail.php” – I thought of adding both to see if any is triggered. A note, when I remove the ajaxFrom triggers “sendEmail.php” is carried out.
So what am I doing wrong? What should change to make the “sendEmail.php” carried out.
Also why do I see the success & completer alert twice?
Success => complete => success => complete
The basic form:
<form id="formmail" class="form-horizontal" name="formmail" method="POST" action="sendEmail.php" enctype="multipart/form-data">
.
.
.
I tried (separately of course) both with a submit button:
<input class="btn btn-sm" name='submit' type='submit' id='submit' tabindex='100' value="Submit"/>
And a simple button:
<button class="btn btn-sm" name='submit' id='submit'>Submit</button>
The javascript:
var progress
$(document).ready(function(){
$("#submit").click(function(){
var form_data = $("#formmail").serialize();
$("#formmail").ajaxForm({
type: "POST",
url: "sendEmail.php",
data: form_data,
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){
alert("success");
},
complete: function(xhr){
if(xhr.responseText) {
alert("complete");
}
},
})
.submit();
});
});