I've been trying to implement a progress bar with AJAX and I'm getting ZERO output from the code. I was wondering if anyone could let me know what I could be missing.
$("#uploadSubmitBtn").click(function(){
var formData = new FormData($("#mediaUploadForm")[0]);
var usersFiles=$("#uploadBtn")[0].files;
formData.append('usersUpload', usersFiles);
$.ajax({
//for our progress bar...
xhr: function() {
//var xhr = new window.XMLHttpRequest();
var xhr = $.ajaxSettings.xhr();
xhr.upload.addEventListener("progress", function(evt) {
alert("attempting progress calculation..");
if (evt.lengthComputable) {
var percentComplete = Math.round( (evt.loaded * 100/ evt.total) );
console.log("percent completed = " + percentComplete);
}
}, false);
return xhr;
},//end xhr function
//other stuff
url : "upload",
type : 'post',
data : formData,
async : false,
cache: false,
processData: false,
contentType: false,
success : function(resp){
$('#msgBoxText').text(resp);
$('#msgBox').slideDown("slow");
},
});
});//end of submitting media