0

I have the following code where I need to set the "status" variable depending on the success or failure of an ajax call.

function loadPMMLAvailability(algorithmName) {
    var status = false;
    if (algorithmName) {

        $.ajax({
            type: "GET",
            url: serverUrl + '/api/configs/pmml/' + algorithmName,
            success: function (res) {
                status = true;
                console.log('Im in success');
            },
            error: function (res) {
                status = false;
            }
        });
    }

    console.log(status);
    return status;
}

In the output I get an "Im in success" and "false" which says that status is false. Why isn't it being set to true?

Tushar
  • 85,780
  • 21
  • 159
  • 179
DesirePRG
  • 6,122
  • 15
  • 69
  • 114

0 Answers0