moved the page reload function into the callback of the api function. Now I know the page won't reload before the data has been updated.