結果 : javascript wait until a function completes