离开页面前的AJAX

this question was often asked, but most of the answers are old and the settings are changed now.

How can I use AJAX right before the user is leaving the page?

JQuery removed unload() in version 3.0.

And window.beforeunload only working with the safety question, if the user is sure about closing the page and losing his input.

But I don't want that question, is there any possibility that for an delay in the beforeunload function?

$(window).on('beforeunload', function(){

    var timeOnPage = [
        end = Date.now(),
        elapsed = end - start
    ];

    $.ajax({
        url: 'tracking_userTime_server.php',
        type: 'POST',
        data: {
            'timeOnPage': timeOnPage
        }
    });

    /*var c=confirm(); //Safety question
    if(c){
        return true;
    }else{
        return false;
    }*/
});