How to assign variable value to the block output of the result of the ajax?

Good time of day.

Trying to implement a rating system for articles on the site. Articles are displayed in a loop, and for each article there is a button "like". Doing this miracle on a bunch of AJAX+PHP. Because articles appear in the cycle then that would not make unnecessary duplicates of the same script on the button put onClik function that will process the request and assign a rating. Here is the code:

$(".urlparam").click(function () {
 var id = $(this).data('id');
 type: "POST",
 url: "/like.php", // Handler
 data: "id="+id,// Post id
 dataType: "html",
 cache: false,
 success: function(data) { 
 // Check that we have responded to the handler, if false it means the user has already voted. And display a message.
 if (data == 'false')
 alert('You already voted!');
 $(".likeborder").html(data); // If the user didn't vote, then put in a paragraph is the total number of votes.


the variable id in the beginning of the code received from button (transmit the ID of the material to which vote). After all the manipulations the script block with the class .likeborder outputs the result. The script itself works but esesn in a loop when displaying records, then vote for entry number 1 and the rating is updated at all because all of them have a block with the class .likeborder.

I thought to implement this issue in this way : in a loop for each class to assign the ID of the article and the script to override the block, which will update the rating. But when you try to make changes to the script :

It was $(".likeborder").html(data); became $(".likeborder"+id).html(data);

The script does not display the new rating in the block with the class likeborder"+id
Business. alert (); that ID is undefined. As far as I know ID has not transmitted in Ajax and do not override the class which displays the result.

Question - how can I pass record ID to override the class which will display the result?

I apologize for the redneck code- I'm not an expert unfortunately in JS , just starting to learn a lot.

UPD: Bug, as it turned out was not in the script and in the attribute - it had a different name and this script gave undifined because he didn't see the value of the attribute.
var id = $(this).data('id'); changed to var id = $(this).attr('data-numaid');
July 9th 19 at 10:27

Find more questions by tags AJAX