Last active
February 10, 2021 08:29
-
-
Save stefandobre/726d37e04d85ff0daac76534b696cf0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In case the browser asynchronously called the server via AJAX, | |
this is how we can handle that request in JavaScript (MLE) | |
*/ | |
let response = {}; | |
try { | |
// execute any business logic here | |
apex.conn.execute(…); | |
// dummy response | |
response = { | |
status: 'success', | |
anArray: [1, 2, 3], | |
nestedObject: { | |
simple: 'nesting' | |
} | |
}; | |
// JSON operations are trivial | |
response.nestedObject.simple = 'alteration'; | |
} catch(e) { | |
// in case of any errors, rollback any changes | |
// and inform the browser of the error if in debug mode | |
apex.conn.rollback(); | |
response.status = 'error'; | |
if(apex.env.debug != 'NO'){ | |
response.message = e.ORACLE_ERROR_MSG; | |
} | |
} | |
// sending the response back to the browser | |
apex.conn.execute('begin sys.htp.p(:1); end;', [JSON.stringify(response)]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment