Commit 1ce376f8 authored by Mat's avatar Mat

ajax callback, sépare condition readystate et status pour chaque fonction

parent 84a9912f
...@@ -115,12 +115,18 @@ ...@@ -115,12 +115,18 @@
submitURL = Routing.generate('api_owner_update', {'id': ownerId}); submitURL = Routing.generate('api_owner_update', {'id': ownerId});
getAJAX(submitURL, function() getAJAX(submitURL, function()
{ {
if (this.readyState === 4 && this.status === 200) if (this.readyState === 4)
{ {
let json = JSON.parse(this.responseText); if (this.status === 200 || this.status === 0)
form.querySelector('#owner_firstname').value = json.firstname; {
form.querySelector('#owner_lastname').value = json.lastname; let json = JSON.parse(this.responseText);
form.parentNode.classList.remove('hidden'); 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 @@ ...@@ -140,7 +146,7 @@
deleteAJAX(submitURL, function() deleteAJAX(submitURL, function()
{ {
if (this.readyState === 4) { if (this.readyState === 4) {
if (this.status === 200) if (this.status === 200 || this.status === 0)
{ {
reloadTableOwner(); reloadTableOwner();
} }
...@@ -197,7 +203,7 @@ ...@@ -197,7 +203,7 @@
{ {
if (this.readyState === 4) if (this.readyState === 4)
{ {
if (this.status === 200) if (this.status === 200 || this.status === 0)
{ {
reloadTableOwner(); reloadTableOwner();
form.parentNode.classList.add('hidden'); form.parentNode.classList.add('hidden');
......
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 to comment