0

I'm attempting to implement $.get to retrieve a status from a method inside my myreport/index.cshtm.cs page. The get along with the method call work find although the method is not async because there is nothing in it to implement await. The problem is how long it takes to get a response. It's executing the 'return errorMsg' before setting errorMsg inside $.get. How can I implement an await or promise to wait for the response message to complete before continuing on?

I added a async/await but no luck.

let isCgcFiltersUrl = "/myreport/index/iscgcfilters";

function ValidateClient() {
  let errorMsg = String.empty;
  $.get(isCgcFiltersUrl, async function (response) {
    errorMsg = (await response)
      ? String.empty
      : "An error occurred for this client";
  });

  return errorMsg;
}
Phil
  • 157,677
  • 23
  • 242
  • 245
Dustin
  • 23
  • 5

0 Answers0