Hello, I use very often a code by Malcolm Hollingsworth that lets me get/post/... data from the server.
net.download({ method: 'POST', url: Ti.App.Properties.getString('REST')+'login', timeout: 500, type: 'json', param: {password:password_tf.getValue(),session_id:1a75hf654}, success: function (success) { Ti.API.info(success); Ti.App.Properties.setObject("sessionData",success); Ti.App.fireEvent('loginComplete'); }, error: function (error) { Ti.API.info(error); alert("ERROR"); }, progress: function (progress) { Ti.API.info(progress.value); }, state: function (state) { // Ti.API.info(state); } });The success body of this code may result in very large portions of code, so I would like to implement it as a separate commonJS module. So, first of all, I would like to know if this is possible. If it is possible, can I reference views, windows (etc.) that are in the window where I put this code? Or should I pass them to the success function?
Is there any other way to "compact" a little this code? Problem is I use it many times in the same CommonJS window and anything can become very... "verbose" :-)
Thanks.