Pregunta

Estoy cargando con el complemento Ajaxupload y estoy usando esta función en el evento OnComplete de ajaxupload;

function degis(){
var a = "<?php echo $id; ?>";
document.getElementById("imga").src = "../artwork/"+a+"/logo.jpg?dummy=371662";
document.getElementById("imga").style.width = "500px";
document.getElementById("imga").style.height = "175px";
}

pero la nueva imagen cargada no aparece por alguna razón. intenté eso "? dummy = 371662" pero no funcionó.

también estoy usando esto para el evento Onsubmit de ajaxupload

function updeg(){
var a = "uploading.gif";
document.getElementById("imga").style.width = "50px";
document.getElementById("imga").style.height = "50px";
document.getElementById("imga").src = a;

}
</script>

este es el html de este elemento

 <img id="imga" alt="" height="175px" src="../artwork/<?php echo $id; ?>/logo.jpg?dummy=371662" width="500px">

¿Alguna sugerencia sobre esto?

¿Fue útil?

Solución

Según sus ediciones y comentarios anteriores, creo que necesita algo como esto:

function junk() {
    return (new Date()).getTime() + Math.round(Math.random());
}

function degis() {
    var img = document.getElementById("imga");
    if (img) {
        img.src = "../artwork/<?php echo $id; ?>/logo.jpg?nocache=" + junk();
        img.style.width = "500px";
        img.style.height = "175px";
    }
}

Su intento anterior de omitir el caché no funciona porque su " ficticio " El valor es el mismo cada vez. Mediante el uso de una función junk () , como se indicó anteriormente, obtiene un valor aleatorio diferente cada vez, lo que garantiza que la imagen no se pueda almacenar en caché.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top