Today I fooled myself into thinking I could return a variable from an AJAX callback and access it further down the javascript function... NOT!
I will spare you the gory details, and have stripped out all the code except for the alert boxes and the runAction callback
essentially, in my case here, the javascript returned by the runAction callback executes last of all
So I wrote a long "note to self" and thought I would post it here as a "heads up" for the newbies amongst us, might saves someone a bit of time debugging if they stumble across this thread before hand...
I am calling this Javascript function in a UX dialog from the Client-Side Event: onInitializeComplete
My "light bulb moment" for how to handle asynchronous callbacks...
I will spare you the gory details, and have stripped out all the code except for the alert boxes and the runAction callback
essentially, in my case here, the javascript returned by the runAction callback executes last of all
So I wrote a long "note to self" and thought I would post it here as a "heads up" for the newbies amongst us, might saves someone a bit of time debugging if they stumble across this thread before hand...
I am calling this Javascript function in a UX dialog from the Client-Side Event: onInitializeComplete
Code:
function InitTimeSheet() { alert('Begin InitTimeSheet'); //----------------------------------------------------------- // ACTION JAVASCRIPT runAction {dialog.object}.runAction('runSPtoCreateTimesheetRecordsUsingDaysheetID'); // //NOTE: runAction runs asynchronously //it sends a message from the browser to the server, requesting XBasic code to execute on the server //in the meantime, the javascript engine moves on, and the remainder of this function will process. //This code will not wait for the call to the server to actually return javascript back to the browser //(it's asynchronous!) //so any javascript returned from this runAction will very likely execute last of all in the browser //i.e. the code below the dotted line will execute first, before the javascript //is returned from the runAction callback //----------------------------------------------------------- alert('End InitTimeSheet'); //note this alert will pop up before any javascript returned to the browser from the runAction above } //End InitTimeSheet
Comment