javascript - How to use mouse event to do AJAX call only if user is idle for X seconds -
apologies if repost. have seen many examples. can't seem put needs. have "today" page displays groups. throughout day more , more groups appear. want able dynamically update these groups if user has page open , hasn't moved mouse x seconds. have chunk of code: var timeout = null; j$(document).on('mousemove', function() { if (timeout !== null) { cleartimeout(timeout); } timeout = settimeout(function() { timeout = null; //calls page check if there's new data display. if so, wipe existing data , update j$.ajax({ url: "/include/new_groups.php", cache: false, success: function(data){ j$( ".group_container_main" ).append( data ).fadein('slow'); } }) .done(function( html ) { }); }, 3000); }); what doin...