I am trying to get the response text from an URL using ajax. The code below works fine if I set the async
flag to false
but I get a warning from jQuery saying
jquery.min.js:4 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
Here is the code:
function verifyUser()
{
var response = $.ajax({type: "GET", url: "/verify/4512h58", async: false}).responseText;
console.log(response);
}
and if I set the async
flag to true
like so
var response = $.ajax({type: "GET", url: "/verify/112358", async: true}).responseText;
I get undefined
as output. How to solve this?