Return not working in function

0

I have this function, but the return does not work on it, I do not want it to get out of it as long as it does not fit the function:

if ($('#FreteComprador').prop("checked") == true) {
        var id = $("#idtransportador").val();
        var frete = $("#Frete").val();
        if (id == "") {
            alert("Preencha o campo transportador corretamente.");
            return;
        } else {
            var url = "/PedidoFornecedor/VerificaCNPJ";
            $.ajax({
                url: url
                , data: { id: id }
                , type: "POST"
                , datatype: "html"
                , success: function (data) {
                    if (data.resultado == true && frete == "0,00") {
                            alert("É obrigatório preencher o valor do frete.");
                            return;
                    }
                }
            });
        }
    }

How can I do it? In other ifs, when I put return it works, in it it exits the function.

    
asked by anonymous 19.10.2018 / 20:20

1 answer

1

We've been talking and testing, we're missing a async: false as your ajax parameter

    
19.10.2018 / 21:35