Я отправляю проверенное значение флажков в php в массиве.
// tag =['Apple','Mango','Tomato']
var tag = $(this).children().siblings().children().children('input[name="cb"]:checked');
var tagData = [];
$.each(tag, function() {
tagData.push($(this).val());
});
console.log(tagData);
$.ajax({
type: "POST",
url: "script.php",
data: {tag: tagData },
cache: false,
success: function(){
alert("OK");
}
});
Данные Console.log
(2) ["Apple", "Apple"]
0: "Apple"
1: "Apple"
length: 2__proto__: Array(0)
Я получаю этот массив в php вот так.
$list = $_POST['tag'];
$imgTag = implode( ", ",$list);
// i want like this - $imgTag = "Apple,Mango,Tomato".
Но я получаю пустую строку в php.