Commit ba9069c9 by sopham

default image

parent 5cb1cad4
Showing with 14 additions and 6 deletions
...@@ -95,7 +95,6 @@ $(document).ready(function() { ...@@ -95,7 +95,6 @@ $(document).ready(function() {
contentType: false, contentType: false,
processData: false, processData: false,
success: function(data) { success: function(data) {
console.log(data);
$('#imagePreview').css('background-image', 'url('+data +')'); $('#imagePreview').css('background-image', 'url('+data +')');
$('#imagePreview').hide(); $('#imagePreview').hide();
$('#imagePreview').fadeIn(650); $('#imagePreview').fadeIn(650);
...@@ -103,14 +102,23 @@ $(document).ready(function() { ...@@ -103,14 +102,23 @@ $(document).ready(function() {
}); });
}); });
//display image when refresh //display image when refresh, if there is no image display default image
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "avatar-display.php", url: "avatar-display.php",
success: function(data) { success: function(data) {
$('#imagePreview').css('background-image', 'url('+ data +')'); var a = data;
} $.ajax({
url: a,
type: 'HEAD',
error: function() {
$('#imagePreview').css('background-image', 'url(upload/default.png)');
},
success: function() {
$('#imagePreview').css('background-image', 'url('+ data +')');
}
});
}
}); });
}); });
...@@ -33,7 +33,7 @@ if(!isset($_SESSION['loggedin'])) { ...@@ -33,7 +33,7 @@ if(!isset($_SESSION['loggedin'])) {
<label for="imageUpload"></label> <label for="imageUpload"></label>
</div> </div>
<div class="avatar-preview"> <div class="avatar-preview">
<div id="imagePreview" style="background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/20625/avatar-bg.png);"></div> <div id="imagePreview"></div>
</div> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment