Bütün herşeyi doğru yaptığımı düşünüyorum bir çok farklı yerden de ajax silme metodu alıp çalıştırmayı denedim ama çalışmadı bir inceleyebilir misiniz nerede hata var
Web. Php
Route::namespace('Backend')->group(function () {
Route::prefix('Yonetim')->group(function () {
Route::get('/', 'DefaultController@index')->name('Backend.home');
Route::delete('/haberler/deletebooking/{id}','CompanyController@deletebooking')->name('works.deletebooking');
Controller
public function deletebooking($id){
$booking = Games::where('id','=',$id)->first();
$booking->delete();
return response()->json(['success' => true],200);
}
İndex
<td width="5">
<button class="btn btn-danger btn-xs" id="destroy" data-id="{{$game->id}}" data-token="{{ csrf_token() }}">
Sil
<span class="glyphicon glyphicon-trash"></span>
</button>
</td>
<script>
$(".btn").click(function(){
var id = $(this).data('id');
// var $tr = $(this).closest('tr');
$.ajax(
{
url: "/dashboard/booking/deletebooking/"+id,
dataType: "JSON",
type: 'POST',
data: {
'_token': $('meta[name=csrf-token]').attr("content"),
'_method': 'DELETE',
"id": id
},
success: function ()
{
console.log("it Work");
}
});
console.log("It failed");
});
</script>