将html链接变量发送到jquery ajax php文件

将html链接变量发送到jquery ajax php文件,php,jquery,html,ajax,Php,Jquery,Html,Ajax,我想使用jquery检索嵌入在html链接中的变量,spo我可以使用jqueryajax将其发送到php文件。但是我不知道怎么做 这是我写的: <script ...> $("a").click(function(){ $.post("helpers/ajaxcall_country.php", {"HERE I WANT TO SEND THE VARIABLE"}, function(data){

我想使用jquery检索嵌入在html链接中的变量,spo我可以使用jqueryajax将其发送到php文件。但是我不知道怎么做

这是我写的:

    <script ...>
        $("a").click(function(){
             $.post("helpers/ajaxcall_country.php", {"HERE I WANT TO SEND THE VARIABLE"}, function(data){
                $("#countryselect").html(data);
            });
        });
    </script>


    while($row = mysqli_fetch_assoc($all_tags))
    {
        echo "<a id='" . $row['id'] . "' href=''>+</a>&nbsp;&nbsp;";
    }

$(“a”)。单击(函数(){
$.post(“helpers/ajaxcall_country.php”,{“我想在这里发送变量”},函数(数据){
$(“#countryselect”).html(数据);
});
});
while($row=mysqli\u fetch\u assoc($all\u标记))
{
回声“;
}
它将是让我们说20个链接。。。都有不同的“id”。我想用ajax将这个“id”值发送到php文件。你知道怎么做吗?

试试这个:

<script ...>
    $("a").click(function(event){
         $.post("helpers/ajaxcall_country.php", {id: event.target.id}, function(data){
            $("#countryselect").html(data);
        });
    });
</script>

$(“a”)。单击(函数(事件){
$.post(“helpers/ajaxcall_country.php”,{id:event.target.id},函数(数据){
$(“#countryselect”).html(数据);
});
});
试试这个:

<script ...>
    $("a").click(function(event){
         $.post("helpers/ajaxcall_country.php", {id: event.target.id}, function(data){
            $("#countryselect").html(data);
        });
    });
</script>

$(“a”)。单击(函数(事件){
$.post(“helpers/ajaxcall_country.php”,{id:event.target.id},函数(数据){
$(“#countryselect”).html(数据);
});
});

当然我会有document.ready first=)当然我会有document.ready first=)很好的解决方案,如果需要发送url,请使用event.target.hrefnice解决方案添加到该解决方案中,如果需要发送url,请使用event.target.href添加到该解决方案中