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
Here is my HTML
<a href="http://localhost/rightA/en/admin/vacancies/activate/181999/1" class="btn-edit-vacancy"></a>
Here is my javascript
$('.vacancies_tbl').on('click', '.btn-edit-vacancy', function(e) {
e.preventDefault();
var check = postuserWall();
alert(check);
setTimeout(function(){window.location = $(this).attr('href'); }, 4000);
});
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
http://localhost/rightA/en/admin/vacancies/index/undefined
I have also tried the follwing
setTimeout(function(){$(this).trigger("click"); }, 5000);
setTimeout(function(){alert('sdadsa'); $(this).unbind('click') }, 5000);
Here is my function postuserWall i am working on facebook javascript api
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;
}
});
}
the check show me undefined in the alert Thanks