I am developing a website where I have many videos and want to store all video times in to DB before leaving the website just like NETFLIX. I have written REST service in the below function and this function will store data into my DB. But, i am unable to store the details into DB as website is getting closed as soon as rest service called. Is there any other way where I can achieve this?
$(window).bind('beforeunload', function(event) {
}