I’m using jquery and I’m looking to have a user click on a link and load the server response (in this case a one line confirmation) in the same div the link is in. I’ve gone round and round on this and can’t seem to get it right. Here is the code I have from another post on this site which was similar but not close enough for me to grok…
<a href="http://10.0.1.2:8888/?ACT=24&tag_id=8" class="load_link">Add to Watchlist*</a>
<script type="text/javascript">
(function($) {
$(function() {
$('.load_link').click(function() {
$(this).next('div').load(this.href);
return false;
});
});
})(jQuery);
</script>
Any ideas what I’m doing wrong?
Thanks
If the anchor is wrapped inside a div and you want to load the response in this div you could use the
.closest()method:and then:
if there is a div adjacent to the anchor:
then the
.next()method should work.