У меня есть входы, созданные в jQuery, и я хотел бы получить их значения в POST PHP, но в конце я получил ошибку.
function addRow(combi) { //Fonction qui ajouter des élément d'un tableau
//On ajoute autant les cellules
const localisation = combi.localisation;
const garantie = combi.garantie;
const id = `prixmultiplie_${index}`;
const prix = combi.prix;
const tr = $('<tr>').attr('data-id', index);
$(tr).append($('<td>').html(localisation));
$(tr).append($('<td>').html(combi.options.replace(/:::index:::/g, index)));
$(tr).append($('<td>').html(garantie));
$(tr).append($('<td>').attr('id', id).attr('class', 'prix').html(prix));
$(tr).append($('<td>').html(combi.commentaires));
$(tr).append($('<td>').html(combi.actions));
$('#form').append($(`<br />`));
console.log('localisation :', localisation);
console.log('prix :', prix);
console.log('garantie :', garantie);
$('#form').append($(`<input type="hidden" name="localisation[${index}]" id="localisation" value="${localisation}" />`));
$('#form').append($(`<input type="hidden" name="prix[${index}]" id="prix" value="${prix}" />`));
$('#form').append($(`<input type="hidden" name="garantie[${index}]" id="garantie" value="${garantie}" />`));
$('#tableau').append(tr);
index++;
}
<?php
echo '<pre>';
var_dump($_POST);
echo '
';
if ($ _SERVER ['REQUEST_METHOD'] == 'POST')
{
foreach (array_keys ($ _ POST ['price']) как $ key => $ val)
{
echo $ _POST ['цена'] [ключ $]. '-'. $ _POST ['description'] [$ key]. '
';
}
}
У меня должны быть значения, но я получил эти ошибки:
Предупреждение: array_keys () ожидает, что параметр 1 будет массивом, строка указана в
Предупреждение: неверный аргумент указан для foreach () в