I have a page on which there are comments left by users, each message has its own identifier, which is stored in a hidden input tag, to dynamically receive the latest messages that I need, in order to know the identifier of all messages and place them in a line, each identifier should be separated by a comma.
eg...
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); }); } }); }
currently the ignoreMessagesColl variable only finds the first instance of the .activityid class that has a value of "579", but I really need to ignore the MessageColl to have a value of "579, 578, 577"
source share