the another way to get the post_id
by clicking on the link
is to add a data-attribute
to the link. e.g; data-post-id="'.get_the_ID().'"
your html code should look like
<a href="#link" data-post-id="47">Link</a>
then in your js code above the ajax call
var post_id = jQuery(this).attr('data-post-id');
and pass this in your data
object to the ajax call.
data: ({
action: "get_prev_ajax_handler",
url: url,
post_id: post_id,
}),
now you can get the post_id
with $_POST['post_id']
or print_r()
the $_POST
array()