Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
sopham
/
todolist
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ba9069c9
authored
May 13, 2019
by
sopham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default image
parent
5cb1cad4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
function.js
index.php
upload/default.png
function.js
View file @
ba9069c9
...
@@ -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
+
')'
);
}
});
}
});
});
});
});
index.php
View file @
ba9069c9
...
@@ -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>
...
...
upload/default.png
0 → 100644
View file @
ba9069c9
6.27 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment