From 8f3243a075143201dca66f4ddd1737fdcbc01439 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 5 Feb 2015 19:05:18 +0100 Subject: [PATCH] Last HTTP codes handling on client side --- public/js/vroom.js | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/public/js/vroom.js b/public/js/vroom.js index 595f5a8..f3856b3 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -472,19 +472,20 @@ function initAdmin(){ param: {} }) }, - error: function() { - $.notify(locale.ERROR_OCCURRED, 'error'); - }, - success: function(data){ - if (data.status === 'success'){ - roomList = data.rooms; - matches = Object.keys(roomList).length; - updateRoomList($('#searchRoom').val(), 0, itemPerPage); - updatePagination(); + error: function(data){ + data = responseJSON; + if (data.msg){ + $.notify(data.msg, 'error'); } else{ - $.notify(locale.ERROR_OCCURED, 'error'); + $.notify(locale.ERROR_OCCURRED, 'error'); } + }, + success: function(data){ + roomList = data.rooms; + matches = Object.keys(roomList).length; + updateRoomList($('#searchRoom').val(), 0, itemPerPage); + updatePagination(); } }); } @@ -1554,15 +1555,18 @@ function initVroom(room) { }) }, error: function(data) { - $.notify(locale.ERROR_OCCURRED, 'error'); + data = data.responseJSON; + if (data.msg){ + $.notify(data.msg, 'error'); + } + else{ + $.notify(locale.ERROR_OCCURRED, 'error'); + } }, success: function(data) { - if (data.status == 'success' && data.msg){ + if (data.msg){ $.notify(data.msg, 'success'); } - else if (data.msg){ - $.notify(data.msg, 'error'); - } } }); checkMoh(); @@ -2090,10 +2094,16 @@ function initVroom(room) { }) }, error: function(data) { - $.notify(locale.ERROR_OCCURRED, 'error'); + data = data.responseJSON; + if (data.msg){ + $.notify(data.msg, 'error'); + } + else{ + $.notify(locale.ERROR_OCCURRED, 'error'); + } }, success: function(data) { - if (data.status === 'success' && data.msg && data.msg != ''){ + if (data.msg && data.msg != ''){ $.notify(data.msg, { className: 'info', autoHide: false