how to undo event.preventdefault after some time on hyperlink using jquery or javascript <p>I want to my undo event.preventdefault after some time on hyperlink using jquery or javascript. when I click on my link then it should redirect me to the link given in href after some time because i want to send some ajax request in that time</p> <p><strong>Here is my HTML</strong></p> <pre><code>&lt;a href="http://localhost/rightA/en/admin/vacancies/activate/181999/1" class="btn-edit-vacancy"&gt;&lt;/a&gt; </code></pre> <p><strong>Here is my javascript</strong></p> <pre><code>$('.vacancies_tbl').on('click', '.btn-edit-vacancy', function(e) { e.preventDefault(); var check = postuserWall(); alert(check); setTimeout(function(){window.location = $(this).attr('href'); }, 4000); }); </code></pre> <p>the set timeout function is working but after some time it does not redirect me to desired link but it redirect me to this link</p> <pre><code>http://localhost/rightA/en/admin/vacancies/index/undefined </code></pre> <p>I have also tried the follwing</p> <pre><code>setTimeout(function(){$(this).trigger("click"); }, 5000); setTimeout(function(){alert('sdadsa'); $(this).unbind('click') }, 5000); </code></pre> <p>Here is my function postuserWall i am working on facebook javascript api</p> <pre><code>postuserWall(){ var body = 'Usama New Post'; FB.api('/me/feed', 'post', { message: body }, function(response) { if (!response || response.error) { console.log(response); alert('Error occured'); return false; } else { alert('Post ID: ' + response.id); return true; } }); } </code></pre> <p>the check show me undefined in the alert Thanks</p>