i want to use jquery to retrieve a variable embedded in a html link, spo i can send it to the php file with jquery ajax. but i dont know how to do this.
this is what i have written:
<script ...>
$("a").click(functio开发者_运维问答n(){
$.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> ";
}
it will be lets say 20 links ... all with different "id". i want to send this "id" value to php-file with ajax. any idea how to do it?
try this:
<script ...>
$("a").click(function(event){
$.post("helpers/ajaxcall_country.php", {id: event.target.id}, function(data){
$("#countryselect").html(data);
});
});
</script>
精彩评论