Make sure to await ajax promise before reloading page in FIrefox
Make sure to await the resolved promise in Firefox before u refresh, redirect the page or window.history.back() or you might encounter some weird buggy scenarios where the promise javascript error is shown after the page reload for example
let requestPromise = return new Promise(function (resolve, reject) {
    $.ajax({
      url: url,
      type: "POST",
      data: data,
      // ...
      success: function success(response) {
        resolve(response);
      }
     // ...
    })
});
you need to make sure to await this promise inside
async function
before any page reload is executed
async function waitResponse(request_promise){
  let response = await request_promise;
  if(response.success == true){
        // DO WHATEVER YOU WANT WITH THE RESPONSE
        window.history.back(); // <--- and after that u can reload or go back to page or whatever
    }
  }
}

waitResponse(requestPromise);
by გიორგი უზნაძე
11 months ago
JavaScript
Ajax
Promise
0
Pro tip: use ```triple backticks around text``` to write in code fences