0
I have the following function:
function show(msg, el){
    if(msg.alertType == 0){
    resetForm(el);
    setTimeout(function(){                  
        $('#show-toast').removeClass('toast-show');
        $('#show-toast .td.result .msg').remove();
    }, 5000);
    }else if(msg.alertType == 1){
    }etc..
}
function resetForm(form){
    if(form.length){
        form.trigger('reset');
        $(form).find("input[type='text']").each(function( index ) {
            if (!$(this).val())
                $(this).parent().removeClass('is-dirty , is-invalid');
        });
        $('.preview').find('img').attr('src', '#');
    }
}
if($('#form-blog').length){
    $('#enviar-post').click(function(e) {           
        var dados = new FormData($("#form-blog")[0]);
        var form = '#form-cursos';
        dados.append('action', 'insert-blog');
        $.ajax({
            url: 'database/actions.php',
            type: 'POST',               
            data: dados,
            processData: false,
            contentType: false
        })
        .done(function(rtv) {
            var data = JSON.parse(rtv);
            show(data, form);
            console.log("success");
        })
        .fail(function() {
            console.log("error");
        }).always(function(rtv) {
            $('#mdl-console').append(rtv);
        });
        return false;
    });
}
however the function resetForm(el) of error, says that form is undefined
curious, tried it a thousand times and it didn’t work, thank you!
– Hebert Lima
@Hebertdelima, all right, we’ve all been through some syntactic mistakes before ; )
– Lucas
@Hebertdelima resolved?
– Lucas
yes solved ; )
– Hebert Lima