$.ajax({
url: '/script.php',
type: 'post',
data: {'btn_id': 123},
success: function (data, status) {
console.log(data)
},
error: function (xhr, desc, err) {
console.log(xhr);
console.log("Details: " + desc + "\nError:" + err);
}
});
<?php
// http://site.ru/script.php
$post = filter_input(INPUT_POST, FILTER_SANITIZE_STRING);
var_dump($post);
$clear = [];
for ($i = 1; $i <= 10; $i++) {
$clear[] = [
'mesto' => $i,
];
}
$mesta2 = \DB::table('mesta')->where('game_id', 595)->get()->keyBy('mesto');
$result = \Illuminate\Support\Collection::make($clear)->map(function ($item) use ($mesta2) {
if ($persistedItem = $mesta2->get($item['mesto'])) {
return $persistedItem;
}
return $item;
});