I have this:
<div id="userPhoto">
<a href="profil.php?id=<?php echo $sid; ?>">
<img src="images/profilePhoto/thumbs/<?php if($vP["photo"]){ echo $vP["photo_thumb"]; }else{ echo "noPhoto_thumb.jpg"; } ?>" style="float: left; border: 2px solid #CCC; margin-right: 5px; margin-left: 15px; margin-bottom: 2px; width: 44px; height: 48px;">
</a>
</div>
after upload, on success i wish to replace this image(noPhoto.jpg) with the new filename and show it, so a new image appears..
(that exists in newFilename variable)
How can i do this the most simple way?
asked Oct 31, 2010 at 21:52
Johnson
8184 gold badges21 silver badges39 bronze badges
2 Answers 2
$('#userPhoto').find('img').attr('src', ['/your/path/', newFilename].join(''));
answered Oct 31, 2010 at 21:57
jAndy
237k57 gold badges313 silver badges363 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
In your success handler, set the image's source attribute:
$('#userPhoto img').attr('src', newFilename);
If you need more information about how to put this into a success handler, you'll need to show us some more code.
answered Oct 31, 2010 at 21:56
lonesomeday
239k54 gold badges330 silver badges329 bronze badges
Comments
lang-js