I do not really know if the problem is the cache or the script I made or the server I'm using, but come on.
I am using this code to upload a document to the server (I have not yet evaluated security and performance issues).
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 location.reload(true);
method that works perfectly in Firefox, locally works in Chrome and firefox, but when I send to the server it does not work correctly in Chrome. I tested other ways as can be seen commented, always the same result.
When the page is reloaded the new content that has been inserted does not appreciate, having to give F5 again for the data to appear on the screen, I am not loading this content via ajax, it is loaded via normal php on the page. And because the content does not load the form that should disappear, it is still active allowing sending more documents, even if sending more than one document is blocked, this problem passes to the user that the doc was not sent. Since the information does not appear on the screen.