When you need a link to contain info for an AJAX call what is the proper place to put the info?
I’ve always put it in the rel attribute, but reading the documentation for rel it seems this isn’t the proper place:
This attribute describes the
relationship from the current document
to the anchor specified by the href
attribute. The value of this attribute
is a space-separated list of link
types.
You could parse the href and pull out the info you need:
<a class="store_link" href="/store/4/name-of-store">Name of Store</a>
$(".store_link").click( function() {
id = $(this).attr('href').split('/')[2];
});
But links won’t always have hrefs
Is there a proper place to put this information?
I use non-standard HTML attributes, prefixed with
data-See this answer for more details. It won’t validate, but it works perfectly. You need to decide how important 100% validation is to you.