0
I don’t really know if the problem is the cache or the script I made or the server I’m using, but come on.
I’m using this code to upload a document to the server(I haven’t evaluated security and performance issues yet).
if($("#add-doc").isValid()){
$.ajax({
url: 'api/upload-doc.php',
type: 'POST',
data: formData,
beforeSend: function(){
$("#docs-objeto3 #forms").hide();
$("#docs-objeto3 #loader-bar").show().fadeIn('slow');
},
success: function (data) {
console.log(data);
},
cache: false,
contentType: false,
processData: false
xhr: function() { // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // Avalia se tem suporte a propriedade upload
myXhr.upload.addEventListener('progress', function (evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
var porcentagem = percentComplete * 100;
console.log(parseInt(porcentagem)+'%');
$('#docs-objeto3 #loader-bar .loadbar-label').text(parseInt(porcentagem)+'%');
$('#docs-objeto3 #loader-bar .progress-bar').width(parseInt(porcentagem)+'%');
if(porcentagem == 100){
// window.location.reload(true);
location.reload(true);
// document.location.href = 'detalhe-objeto.php?objeto_id='+objeto_id+'&rt=success';
// $(location).attr('href', 'detalhe-objeto.php?objeto_id='+objeto_id+'&rt=success')
}
}
}, false);
}
return myXhr;
},
close: function(){
$("#docs-objeto3 #forms").show();
$("#docs-objeto3 #loader-bar").hide();
}
});
}
Note that I am using the method location.reload(true);
which in Firefox works perfectly, locally works in Chrome and firefox, but when uploading to the server does not work properly in Chrome. I tested other ways as can be seen commented, always the same result.
When the page is reloaded the new content that was inserted does not present, having to give F5 once again for the data to appear on the screen, I am not loading this content via ajax, it is loaded via php normal on the page. And as the content does not load the form that should disappear, it is still active enabling the sending of more documents, even if the sending of more than one documents is blocked this problem passes to the user that the doc was not sent. Since the information does not appear on the screen.
Does the problem only occur in Chrome? Already tested by anonymous browsing?
– Woss
Just in Chrome, I’ve tried anonymous too, same result. I’m suspecting it might be server-side, because local works perfectly. Anyway I’ll open a call on the server.
– Helison Santos
Reload doesn’t just happen when I send a pdf. :(
– Helison Santos
In these cases it is very important to follow the browser console to debug the javascript and the server response to get a clearer sense of what might be happening,
– Rafael Andrade