I have a button within a post which a user can click. Once clicked, an AJAX call is made.
My question is, within my PHP AJAX helper function (located in my theme's function.php) how can I retrieve, for instance, the ID of the post that the request was sent from.
I can get the ID from the markup and pass it in the AJAX call but it seems messy, i.e.
<article id="post-12"> <!-- article content --> </article> // JS var postID = $("article").attr("id");
Is there a better way? Some kind of global that is accessible perhaps?