I have numerous anchor tags on my page that only trigger jQuery actions on the same page.
The don\'t redirect the user to another location, which is the normal expected
Can you reference a fragment on the page that could work as a logical fallback to the non-executed JavaScript action? If so, it makes a lot of sense to reference and have an
id="account"
on the page that could work as a fallback.
Another option is to reference the dynamically loaded content directly; that way you can quite conveniently use the href
in the Ajax call instead of hard-coding what to request in JavaScript somehow; .
Lastly, you can not have the statically in the HTML at all, but instead create it on the fly with jQuery since it's only used by jQuery anyway. No need to pollute the markup with placeholders for JavaScript if the placeholders are only used by and for JavaScript anyway.
Regarding "sending the user to the top of the page"; you should just return false
from your the function you have hooked up as a click()
handler;
$('a').click(function() {
// Do your stuff.
// The below line prevents the 'href' on the anchor to be followed.
return false;
});