From fd9dcd006be775b6df635400ede9c9571777753e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 4 Feb 2015 23:04:04 +0100 Subject: [PATCH] HTTP codes in update_room_conf API call --- public/js/vroom.js | 24 ++++++++++++------------ vroom.pl | 6 ++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index 1bdcd0a..ab787e0 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -307,21 +307,21 @@ $('#configureRoomForm').submit(function(e){ } }) }, - error: function() { - $.notify(locale.ERROR_OCCURRED, 'error'); - }, - success: function(data) { - $('#ownerPass,#ownerPassConfirm,#joinPass,#joinPassConfirm').val(''); - if (data.status == 'success'){ - $('#configureModal').modal('hide'); - // Hide passwords inputs too - $('#joinPassFields,#ownerPassFields').hide(); - $.notify(data.msg, 'info'); - $('#configureRoomForm').trigger('room_conf_updated'); + error: function(data) { + data = data.responseJSON; + if (data.msg){ + $.notify(data.msg, 'error'); } else{ - $.notify(data.msg, 'error'); + $.notify(locale.ERROR_OCCURRED, 'error'); } + }, + success: function(data) { + $('#ownerPass,#ownerPassConfirm,#joinPass,#joinPassConfirm').val(''); + $('#configureModal').modal('hide'); + $('#joinPassFields,#ownerPassFields').hide(); + $.notify(data.msg, 'info'); + $('#configureRoomForm').trigger('room_conf_updated'); } }); }); diff --git a/vroom.pl b/vroom.pl index 90db104..bf0a3da 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1455,8 +1455,10 @@ any '/api' => sub { return $self->render( json => { status => 'error', - msg => $self->l('ERROR_OCCURRED') - } + msg => $self->l('ERROR_OCCURRED'), + err => 'ERROR_OCCURRED' + }, + staus => 503 ); } # Handle password (join and owner)