In my requirement, a user can select multiple check-boxes. However after checking each check-box I need to call the URL and pass selected checkbox value with time-delay of 3 seconds. This delay is required, so that user can select/de-select another checkbox, old action should be canceled and new selected value(s) should be passed.
I know to call a function with delay, but don’t know how to stop the last action with the new one.
setTimeout(function(){ call_me(action) },3000);
function call_me(action)
{
var url = action
$(location).attr('href',url);
}
You have to use
clearTimeout(), but first you need to assign the return of the setTimeout to a variable.