pfff. fixed :]
$(".button").click(function() { var command = $(this).attr("ID"); elements = new Array(); $(".elementSelected").each(function() { var wordsSelected = $(this).html(); elements.push(wordsSelected+','); }); $.get('interpreter.php', { cmd: command, elmnt: elements },function(data){ $("#output").replaceWith(data); });