I Have a page which has comments left by users, each post has has its own id which is stored in a hidden input tag, in order to dynamically get the latest posts I need to know the id's of all posts and place them in a string, each id needs to be separated by a comma.
for example...
HTML markup
<div class='msgPost'><div class='msgContainer'>
<input class='activityId' type='hidden' value='579'>
<span>
<div class='name'>Bob</div>nm
</span>
</div>
<div class='msgPost'><div class='msgContainer'>
<input class='activityId' type='hidden' value='578'>
<span>
<div class='name'>Tom</div>4
</span>
</div>
<div class='msgPost'><div class='msgContainer'>
<input class='activityId' type='hidden' value='577'>
<span>
<div class='name'>John</div>123
</span>
</div>
Jquery code
function getLatestActivities(){
var ignoreMessagesColl = $("input.activityId").val();
$.ajax({
traditional: true,
dataType: "json",
type: "GET", url: "include/process.php",
data:{
getLatestActivity: "true",
toUser: "4",
ignoreMessages: ignoreMessagesColl
},
success: function(data){
$.each(data, function (i, elem) {
$('.commentMessage').after(elem.value);
});
}
});
}
at the moment the variable ignoreMessagesColl only finds the first class instance of .activityid which has the value "579", but i actually need ignoreMessageColl to have the value "579, 578, 577"