How to make one function execute the next function after it is finished in js

clipboard.png
this is the code. When I click on the switch language section, I have to request a new English menu again.
getAgent () is the function for me to request the English menu, but there is still some data that must be refreshed to get
no matter I choose
window.location.reload (true);.
doesn"t work before or after getAgent (). I just want to refresh the page after the getAgent () function has been executed. Thank you

.
Mar.04,2021

  1. callback
  2. promise

getAgent () is a request method so you can use promise to do


es6 async function you deserve to have.


the simpler one: use callback.

let callback = () => { window.location.reload(true) };

getAgent(callback);

function getAgent(callback) {
  // ...
  callback();
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36d3b-2b7c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36d3b-2b7c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?