I’m learning about JavaScript’s Promise function and I expect to run the following in sequence:
- Do_System_Refresh(); –> In this function, I call the AJAX function within System_Refresh() for some purposes.
- Do_Refresh_UI();
I tried the following, but I encountered an exception: Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received.
async function Do_System_Refresh()
{
let p = new Promise(function(Do_Refresh) {
Do_Refresh_UI();
});
await System_Refresh();
}
async function System_Refresh()
{
call ajax here
}
function Do_Refresh_UI()
{
alert('here do refresh called');
}
What did I do wrong?
I need advice, many thanks in advance.