1

I am doing an ajax call in the following manner and I want to get the response to an outer variable but I dont want to have async as false as

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

Please help me regarding how to do this without having async as false

let getUser = (emailID) =>{
    let userData;
    let json ={
        'email': emailID
    };
    $.ajax({
        async: false,
        type:'post',
        url:'getUserDetails.php',
        data: {userEmailAddress:json},
        success:function(response){
            if(response.status == 'success'){
               userData = response.DATA;
            }else if(response.status == 'error'){
                console.log('Failed');
                console.log(response);
            }
        },
        error:function(response){
            console.log('ajax fail');
            console.log(response);
        }
    });
    console.log(userData);
    return userData;
    };
Summy
  • 443
  • 3
  • 5
  • 14

0 Answers0