-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.js
52 lines (46 loc) · 1.95 KB
/
report.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$(document).ready(function(){
$("#form").on('submit', function(e){
e.preventDefault();
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
var percentComplete = Math.floor((evt.loaded / evt.total) * 100); //nearest integer point.
$(".progress-bar").width(percentComplete + '%');
$(".progress-bar").html(percentComplete+'%');
}
}, false);
return xhr;
},
type: 'POST',
url: 'reportup.php',
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
beforeSend: function(){
$(".progress-bar").width('0%');
//$('#statusMsg').html('<img src="images/loading.gif"/>');
},
error:function(){
$('.statusMsg').html('<p style="color:#EA4335;">File upload failed, please try again.</p>');
},
success: function(response){
var response = JSON.parse(response);
$('.statusMsg').html('');
if(response.status == 1){
$('#form')[0].reset();
$('.statusMsg').html('<p style="color:#28A74B;">'+response.message+'</p>');
$(".statusMsg").delay(1500).fadeOut();
getData();
}else{
$('.statusMsg').html('<p style="color:#EA4335;">'+response.message+'</p>');
$(".statusMsg").delay(1500).fadeOut();
}
$('#form').css("opacity","");
$(".submitBtn").removeAttr("disabled");
}
});
});
});