I have a default image which is loaded in the HTML. Then i check if a personal image exists with an ajax request, the request is succesful however it cannot set the new image src. The image loaded from HTML is always displayed. The code to set the new image src works if it is outside the ajax request. This is my code:
<img id="imageid" src="media/default/slider.jpg" alt=""/>
...
<script type="text/javascript">
$.ajax({
url:'media/' + loginmail + '/slider.jpg',
type:'GET',
dataType: "image/gif",
error: function()
{
},
success: function(data)
{
alert("success" );
$('#imageid').attr('src', "media/" + loginmail + "/slider.jpg");
}
});
Thank you. EDITED:
I really do not know if it changes something but i am using the http://slimimagecropper.com/ Plugin.
<div id="my-cropper" class="slim" style="width:1200px; height: 300px; border:0;"
data-service="async.php"
data-fetcher="fetch.php"
data-ratio="12:3"
data-size="1200,300"
data-label="Insert here your image">
<img id="imageid" src="media/default/slider.jpg" alt=""/>
<input type="file" accept="image/jpeg, image/png" name="slim[]"/>