javascript - Wait for asyn call to finish - too late -
i have dialog button. once clicked button calls async method returns true or false depending on whether posted data valid or not. click event calls method below. now, problem closedialog called before callback function executed!! how can make work?
thanks
close: function (srccmd) { var closeresult = true; asyncthing(function(result) { if (result) closeresult = true; else closeresult = false; }); if (closeresult !== false) { this.closedialog(); } },
the function withing asyncthing called when(whenever might be) asynchronous call finished. not interpreted line-by-line.
move latter if question callback function , fine.
close: function (srccmd) { var closeresult = true; asyncthing(function(result) { if (result) closeresult = true; else closeresult = false; if (closeresult !== false) { this.closedialog(); } }); },
Comments
Post a Comment