(JQuery) How to call a custom function before following link
Posted
by morpheous
on Stack Overflow
See other posts from Stack Overflow
or by morpheous
Published on 2010-04-22T22:08:08Z
Indexed on
2010/04/22
22:13 UTC
Read the original article
Hit count: 153
jQuery
I want to achieve the following behavior in a page link.
When the link is clicked, I want to:
- First, send (POST) some data back to the server
- Second, allow the browser to navigate to the url that the link was pointing to.
I am relatively new to JQuery, and here is my first attempt below. I will be grateful to any jQuery gurus in here to fillin the blanks (and maybe point out how the snippet below may be improved).
<html>
<head>test page</head>
<body>
<div><a id="hotlink" href="http://www.example.com">Clik and see</a></div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$('hotlink').click(function(){
//AJAX Post data here ...
//follow the link url (i.e. navigate/browse to the link) ...
});
});
</script>
</html>
© Stack Overflow or respective owner