views:

66

answers:

1

Hi all

i am making an upload with Ajaxupload plugin and i am using this function in OnComplete event of 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";
}

but new uploaded image doesnt appear for a reason. i tried that "?dummy=371662" but didnt work.

i am also using this for Onsubmit event of 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>

this is the html of this element

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

Any suggestions on this ?

A: 

Based on your edits and comments above, I think you need something like this:

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";
    }
}

Your previous attempt to bypass the cache doesn't work because your "dummy" value is the same each time. By use of a junk() function, as above, you get a different random value each time, ensuring that the image cannot be cached.

Warren Young
ok but without that modification how can i change image after upload process?
Ahmet vardar
oh sorry you are talking about height and width, i am changing it because there is one more function for OnSubmit event of ajaxupload which is change height and width, i am editing my question
Ahmet vardar
Edited to answer the current question and comments.
Warren Young
thank you so much, it works great
Ahmet vardar