Fix response handling

This commit is contained in:
Dennis Eichhorn 2018-03-24 19:48:28 +01:00
parent 86dfb12b07
commit f6e2f23ece

View File

@ -214,13 +214,12 @@
request.setSuccess(function (xhr) request.setSuccess(function (xhr)
{ {
console.log(xhr.response); console.log(xhr.response);
try { try {
const o = JSON.parse(xhr.response), const o = JSON.parse(xhr.response),
response = new jsOMS.Message.Response.Response(o), response = new jsOMS.Message.Response.Response(o);
responseLength = response.count();
let tempResponse = null, let tempResponse = null,
success = null; successInject = null;
if (typeof o.status !== 'undefined') { if (typeof o.status !== 'undefined') {
self.app.notifyManager.send( self.app.notifyManager.send(
@ -228,15 +227,10 @@
); );
} }
/* Handle responses (can be multiple response object) */ if ((successInject = form.getSuccess()) !== null) {
for (let k = 0; k < responseLength; ++k) { successInject(tempResponse);
tempResponse = response.getByIndex(k); } else {
self.app.responseManager.run(tempResponse.type, tempResponse, request);
if ((success = form.getSuccess()) !== null) {
success(tempResponse);
} else {
self.app.responseManager.run(tempResponse.type, tempResponse, request);
}
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);