結果 : javascript wait till a function completes