Проверил на
PHP index.php"
<?php
$specs = json_decode($_POST['specs'], true);
print_r($specs);
var_dump($specs);
?>
в браузере запускаю
fetch("index.php", {
method: "post",
body: new URLSearchParams({
specs: JSON.stringify([{name: "1", spec: "111"}, {name: "111", spec: "111"}, {name: "111", spec: "111111"}]),
})
})
.then(response => response.text())
.then(console.log)
Всё работает, в консоли пишет
Код:
|
Array
(
[0] => Array
(
[name] => 1
[spec] => 111
)
[1] => Array
(
[name] => 111
[spec] => 111
)
[2] => Array
(
[name] => 111
[spec] => 111111
)
)
array(3) {
[0]=>
array(2) {
["name"]=>
string(1) "1"
["spec"]=>
string(3) "111"
}
[1]=>
array(2) {
["name"]=>
string(3) "111"
["spec"]=>
string(3) "111"
}
[2]=>
array(2) {
["name"]=>
string(3) "111"
["spec"]=>
string(6) "111111"
}
} |