function postreq(event, fid) {
    event.preventDefault();

    let form = $('#' + fid);
    let $sbutton = form.find('button');
    let lstext = $sbutton.text();
    $sbutton.attr('disabled', true).html(renderIconTag('link')+"Sending Verification Link");

    let formData = $('#' + fid)[0];
    // Create an FormData object
    let fd = new FormData(formData);
    $('#preloader').show();
    $.ajax({
        url: form.attr('action'),
        type: "POST",
        data: fd,
        
        processData: false,
        contentType: false,
        success: function (data, textStatus, jqXHR) {
            let count = data.data;
            let si = setInterval(() => {
                if (count == 0) {
                    $sbutton.attr('disabled', false).html(renderIconTag('link')+lstext);
                    clearInterval(si);
                } else {
                    $sbutton.html(renderIconTag('link')+`Request new  link ${count} seconds`);
                }
                count--;
            }, 1000);
            //data - response from server
            $('#preloader').hide();
            $('.textdanger').remove();

            if (data.email) {
                $('#loggedin_user_title').text(data.email);
            }

            if (data.status == true) {
                swalMsg(data.msg,'success');
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {

            if (globalErrorHandler(jqXHR.responseJSON))
                return false
            $sbutton.attr('disabled', false).html(renderIconTag('link')+lstext);
            $('.textdanger').remove();
            $.each(jqXHR.responseJSON.errors, function (field_name, error) {
                let field = $(document).find('[name=' + field_name + ']');
                if (field.parent().hasClass('input-group')) {
                    field.parent().after('<span class="text-strong textdanger text-danger">' + error + '</span>')
                } else {
                    field.after('<span class="text-strong textdanger text-danger">' + error + '</span>')
                }
            })

        }
    });
}
