From f6e2f23ecea0b3ac50b256daae0b8a7e0f2c04a3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 24 Mar 2018 19:48:28 +0100 Subject: [PATCH] Fix response handling --- UI/Component/Form.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 8383ead..2312ff1 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -214,13 +214,12 @@ request.setSuccess(function (xhr) { console.log(xhr.response); - + try { const o = JSON.parse(xhr.response), - response = new jsOMS.Message.Response.Response(o), - responseLength = response.count(); + response = new jsOMS.Message.Response.Response(o); let tempResponse = null, - success = null; + successInject = null; if (typeof o.status !== 'undefined') { self.app.notifyManager.send( @@ -228,15 +227,10 @@ ); } - /* Handle responses (can be multiple response object) */ - for (let k = 0; k < responseLength; ++k) { - tempResponse = response.getByIndex(k); - - if ((success = form.getSuccess()) !== null) { - success(tempResponse); - } else { - self.app.responseManager.run(tempResponse.type, tempResponse, request); - } + if ((successInject = form.getSuccess()) !== null) { + successInject(tempResponse); + } else { + self.app.responseManager.run(tempResponse.type, tempResponse, request); } } catch (e) { console.log(e);