Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,

Below is my code

I want to execute second method only after first method finshes ,

but here .. seond method gets called in between and then executing first and then second .happening something strange

C#
viewModelDocCall.ReportCall = function () {
        if (isConnectionAvailable()) {
            callData.GetAvailableCoOrdinates(true, viewModelDocCall.customerLocationID(), function (tx, coOrdinates) {
                if (null != coOrdinates && coOrdinates.rows.length > 0) {
                    if (!(validator.IsNullOrWhiteSpace(coOrdinates.rows.item(0).Latitude)) ||
                        !(validator.IsNullOrWhiteSpace(coOrdinates.rows.item(0).Longitude))) {
                        var result = DevExpress.ui.dialog.confirm(Messagehandling.getMessage('AP067', 'Are you currently at the meeting location?'), Common.Localize("Delete"));
                        result.done(function (dialogResult) {
                            if (dialogResult) {
                                dCall_GetCoOrdinatesClicked();
                            }
                        });
                    }
                }

            }, function (tx, coOrdinatesError) {

            });
        }
       //Call second method here
    }


What I have tried:

viewModelDocCall.ReportCall = function () {
if (isConnectionAvailable()) {
callData.GetAvailableCoOrdinates(true, viewModelDocCall.customerLocationID(), function (tx, coOrdinates) {
if (null != coOrdinates && coOrdinates.rows.length > 0) {
if (!(validator.IsNullOrWhiteSpace(coOrdinates.rows.item(0).Latitude)) ||
!(validator.IsNullOrWhiteSpace(coOrdinates.rows.item(0).Longitude))) {
var result = DevExpress.ui.dialog.confirm(Messagehandling.getMessage('AP067', 'Are you currently at the meeting location?'), Common.Localize("Delete"));
result.done(function (dialogResult) {
if (dialogResult) {
dCall_GetCoOrdinatesClicked();
}
});
}
}

}, function (tx, coOrdinatesError) {

});
}

alert("Called second method")

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900