Execute AJAX and then follow the Link (standard action)

Execute AJAX and then follow the Link (standard action)

Hello all together,

i would like to count the clicks on all links on my homepage.
To do this, i added an onclick action to execute my AJAX-Script, to count the click on the link.
The user should be automatically redirected to the original link target.
But sometimes, the AJAX Skript is too slow, and the default action (redirect to the page) ist already executed, before the AJAX script ends.

I tried to solve this problem by preventing the default action, and then redirect the user via "window.location".
This works, but I would like to open the window in a new window. If I do this via Javascript, Popup Blocker will block this.

This is the code, to open the target in the same window.
  1.     $(document).ready(function() {

        $("a").click(function(event) {
                    event.preventDefault();

                    var link_target = $(this).attr('href');
                    var link_text = $(this).text();

                    var request = $.ajax({
                    url: "count.php",
                    type: "POST",
                    data: {link_target : link_target, link_text : link_text},
                    dataType: "html"
                    });

                    request.done(function(msg) {           
                        window.location.href = link_target;
                    });

            });
           
        });






















So I think the Javascript-Redirct is not the best solution.
Has anybody an idea, how to solve this?

Thanks in advance.