Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mathieu
technobel.sf
Commits
1ce376f8
Commit
1ce376f8
authored
May 18, 2018
by
Mat
Browse files
ajax callback, sépare condition readystate et status pour chaque fonction
parent
84a9912f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/TechnoBundle/Resources/views/Ajax/Owner/mainDisplay.html.twig
View file @
1ce376f8
...
...
@@ -115,12 +115,18 @@
submitURL
=
Routing
.
generate
(
'
api_owner_update
'
,
{
'
id
'
:
ownerId
});
getAJAX
(
submitURL
,
function
()
{
if
(
this
.
readyState
===
4
&&
this
.
status
===
200
)
if
(
this
.
readyState
===
4
)
{
let
json
=
JSON
.
parse
(
this
.
responseText
);
form
.
querySelector
(
'
#owner_firstname
'
).
value
=
json
.
firstname
;
form
.
querySelector
(
'
#owner_lastname
'
).
value
=
json
.
lastname
;
form
.
parentNode
.
classList
.
remove
(
'
hidden
'
);
if
(
this
.
status
===
200
||
this
.
status
===
0
)
{
let
json
=
JSON
.
parse
(
this
.
responseText
);
form
.
querySelector
(
'
#owner_firstname
'
).
value
=
json
.
firstname
;
form
.
querySelector
(
'
#owner_lastname
'
).
value
=
json
.
lastname
;
form
.
parentNode
.
classList
.
remove
(
'
hidden
'
);
}
else
if
(
this
.
status
===
400
)
{
console
.
log
(
'
BAD REQUEST. DISPLAY ERRORS
'
);
}
}
});
});
...
...
@@ -140,7 +146,7 @@
deleteAJAX
(
submitURL
,
function
()
{
if
(
this
.
readyState
===
4
)
{
if
(
this
.
status
===
200
)
if
(
this
.
status
===
200
||
this
.
status
===
0
)
{
reloadTableOwner
();
}
...
...
@@ -197,7 +203,7 @@
{
if
(
this
.
readyState
===
4
)
{
if
(
this
.
status
===
200
)
if
(
this
.
status
===
200
||
this
.
status
===
0
)
{
reloadTableOwner
();
form
.
parentNode
.
classList
.
add
(
'
hidden
'
);
...
...
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