I'm trying to pass some data via Jquery to another php page.
I create tag < a >
via echo
:
echo "<a id='".$feed_id."' class='like'> Teste LINK </a>";
• The variable $ feed_id should return a numeric ID (eg 1234)
I have the function:
$(document).ready(function(){
$("#like").click(function(){
var url = "like.php";
var data = $("#like").attr("id");
$.post(url,{postdata:data},
function(result) {
$("#result").html(result); // Só pra verificar retorno
});
});
And I try to get the value of the variable in the page like.php:
$data = $_POST['postdata'];
echo $data;
I need some tips to make this code work, and if possible, improve it.