Question: I am calling the below function from my **.aspx** page and all I want to check whether this function returned `true` or `false`. I tried many things but I get undefined as result.

I am calling function using below code

```
 if (IsIncetiveAllowed())
    {
        sCondition = ".//LISTENTRY[VALUEID='" + m_sIncentiveReleaseId + "']";
        xmlNode = $(XMLCombos).xpath(sCondition)[0];
        XMLCombos.firstChild.removeChild(xmlNode);
    }

function IsIncetiveAllowed() {
$.ajax({
        cache: false,
        async: false,
        type: "POST",
        url: "pp060.aspx/CheckIncentiveAllowed",
        data: "{'typeOfApplication': '" + m_TypeOfMortgage + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {

            if (response.d)
                return true;
            else
                return false;
        },
        error: function (response) {
            MessageBox.Show("An error occurred checking IsIncetiveAllowed method.", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    });
}

```

Please Help!

Answer: 
If you pass a callback to the `IsIncetiveAllowed` function, you can make it execute your code with the result of the ajax call after it has been made.

```
IsIncetiveAllowed(function(is_allowed) {
    if (is_allowed) {
        sCondition = ".//LISTENTRY[VALUEID='" + m_sIncentiveReleaseId + "']";
        xmlNode = $(XMLCombos).xpath(sCondition)[0];
        XMLCombos.firstChild.removeChild(xmlNode);
    }
    else {
        // Not allowed
    }
});

function IsIncetiveAllowed(callback) {
    $.ajax({
        cache: false,
        async: false,
        type: "POST",
        url: "pp060.aspx/CheckIncentiveAllowed",
        data: "{'typeOfApplication': '" + m_TypeOfMortgage + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            if (response.d)
                callback(true);
            else
                callback(false);
        },
        error: function (response) {
            MessageBox.Show("An error occurred checking IsIncetiveAllowed method.", null, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    });
}

```
Well this is happening because the ajax call is asynchronous. You can put your code present in if block to the ajax callback function to implement your logic