Unexpectedly unwanted method is calling while another method calling

Viewed 26

When I clicked the next button to move the next page, updatePolicyDetails() is calling. But at that moment, unexpected popup is showing.

enter image description here

But I didn't call that kind of method inside the updatePolicyDetails() method. So I need to avoid this popup message.

This the method for popup message.

function awareDisclaimerChanges(vetFee, dentalCover, farewellCover, missingCover) {
    let statement = $("<ul></ul>");
    if (vetFee || dentalCover || farewellCover){
        statement.append("<li>14 day waiting period for Illnesses from today</li>");
    }
    if (vetFee || farewellCover){
        statement.append("<li>48 hour waiting period for Accidents from today</li>");
    }
    if (vetFee){
        statement.append("<li>Waiting period only applies to the increased amount of cover</li>");
    }
    if (missingCover){
        statement.append("<li>14 day exclusion period for Missing Pet cover from today</li>");
    }
    $('#policyDetailsToolTipTitle').text('Information');
    $('#policyDetailTooltipsBody').empty();
    $('#policyDetailTooltipsBody').append(statement);
    $('#policyDetailTooltips').modal('show');
}

I call this method like this.

if (autoRenewalQuote){
    if ($('#farewellYesPet' + id).is(':checked')){
        awareDisclaimerChanges(false,false,true,false);
    }

updatePolicyDetails()

function updatePolicyDetails() {
    var isValidFormFieldsWithoutCovers = $('#policyDetailsForm').valid();
    var isValidCovers = validatePolicyDetailsForm();
    if (isValidFormFieldsWithoutCovers && isValidCovers) {
        $("#loaderModal").modal("show");
        var form = $('#policyDetailsForm');
        var noOfPets = $('#noOfPets').val();
        var properties = [];
        for (var i = 1; i <= noOfPets; i++) {
            var extras = [];
            var covers = [];
            var dental = {
                name: "DENTAL_ILLNESS_COVER",
                value: $("input[name='dentalRadioBoxPet" + i + "']:checked").val()
            };
            var missing = {
                name: "MISSING_PET_COVER",
                value: $("input[name='missingRadioBoxPet" + i + "']:checked").val()
            };
            var travel = {
                name: "TRAVEL_AND_HOLIDAY_COVER",
                value: $("input[name='travelRadioBoxPet" + i + "']:checked").val()
            };
            var farewell = {
                name: "FAREWELL_COVER",
                value: $("input[name='farewellRadioBoxPet" + i + "']:checked").val()
            };
            extras.push(dental);
            extras.push(missing);
            extras.push(travel);
            extras.push(farewell);
            var vetFee = {
                name: "VET_FEE",
                value: $('#vetFeePet' + i).val()
            }
            var excess = {
                name: "EXCESS",
                value: $('#excessPet' + i).val()
            };
            var billShare = {
                name: "BILL_SHARE",
                value: $('#billSharePet' + i).val()
            };
            covers.push(vetFee);
            covers.push(excess);
            covers.push(billShare);
            var obj = {
                propertyReference: $('#propRefPet' + i).val(),
                extras: extras,
                covers: covers
            }
            properties.push(obj);
        }
        var params = {
            personReference: $('#personReference').val(),
            quoteReference: $('#quoteReference').val(),
            startDate: $('#policyStartDate').val(),
            isSameCoverForEachPet: 'N',
            properties: properties,
            productType:productType,
            domainType:domainType
        };
        $.ajax({
            type: form.attr('method'),
            contentType: "application/json",
            url: form.attr('action'),
            data: JSON.stringify(params),
            success: function (response) {
                if (response.status == "success") {
                    $("#loaderModal").modal("hide");
                    console.log("55555555555555555555555555");
                    window.location = medicalPageURL + '?quoteReference=' + encodeURIComponent(response.quoteReference) + '&personReference=' + encodeURIComponent(response.personReference) + '&domainType=' + response.domainType + '&productType=' + response.productType + '&nextBtn=' + true + '&breadCrumb=' + 'medical' + '&flow=' + flow;
                } else {
                    $("#loaderModal").modal("hide");
                    $('#commonModalBodyContent').html(response.message);
                    $('#commonModal').modal('show');
                }
            },
            error: function (response) {
                $("#loaderModal").modal("hide");
            }
        });
    }
}

Hope your kind help. thank you.

0 Answers
Related