diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-05-20 21:09:39 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-05-20 21:12:21 +0300 |
commit | 4c65f31abb5695fac3a42a784894d2f6de5869ab (patch) | |
tree | 29abfac4f620b9de2fdf155186b915fc5ac84237 /web | |
parent | 13bc7639a4393331583a3dec7d50ec01969762ca (diff) | |
download | aconf-4c65f31abb5695fac3a42a784894d2f6de5869ab.tar.bz2 aconf-4c65f31abb5695fac3a42a784894d2f6de5869ab.tar.xz |
web client: combine validation error message setting functions
Diffstat (limited to 'web')
-rw-r--r-- | web/client.js | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/web/client.js b/web/client.js index 2e5c86e..1e425c8 100644 --- a/web/client.js +++ b/web/client.js @@ -278,22 +278,7 @@ $(function() { options = {type: "DELETE"} else options = { type: "PUT", - data: JSON.stringify(newValue), - statusCode: { - 422: function(xhr) { - msg.html(_.reduce( - _.map( - $.parseJSON( - xhr.responseText - ), - _.escape - ), - function(a, b) { - return a + "<br/>" + b; - } - )); - } - } + data: JSON.stringify(newValue) } var task = objRequest(path, options); @@ -328,9 +313,19 @@ $(function() { ); }).fail(function(xhr) { - showError(msg, "Error", xhr); - widget.setStatus("invalid"); + if (xhr.statusCode().status == 422) + msg.html(_.reduce( + _.map( + $.parseJSON(xhr.responseText), + _.escape + ), + function(a, b) { + return a + "<br/>" + b; + } + )); + else showError(msg, "Error", xhr); + widget.setStatus("invalid"); setStatus( "invalid", "Some values need checking", |