[jQuery] Overriding a link

[jQuery] Overriding a link


Here's my code:
1. function handleLoading(data) {
2. var $content = $("<div></div>").html(data);
3. var $visualBadge = $("#visualBadge");
4.
5. $visualBadge.children("div").replaceWith($content);
6. $visualBadge.find("a").click(handleClick);
7. }
8.
9. function handleClick(evt) {
10. var link = this;
11. var path = link.href;
12. if(path.indexOf("#") != (path.length-1)){
13. alert(path);
14. $.get(link.href, handleLoading);
15. evt.preventDefault();
16. return false;
17. }
18. }
The $.get on line 14 doesn't complete before the evt.preventDefault();
and return false;
How can I make it complete the get before the evt.preventDefault();
and return false; Remember I need the evt.preventDefault(); and
return false; to keep the original link for loading.
My goal is to hijack the link and make it load its href in my div as
opposed to loading in window.top
Any help would be greatly appreciated!