I am new to Ajax and I am using laravel, now i want to have a delete button that will send the id of the item that i want to delete to controller. Here is my code.
Views
<div class="row">
@foreach($photos as $photo)
<div class="col-xs-3 col-md-1">
<button onclick="removeItem({{$photo->id}}); return false;">Delete</button>
</div>
@endforeach
</div>
Here is my script
<script type="text/javascript">
function removeItem($myvar) {
$.ajax({
type : "POST",
url : "deletephoto",
);}
}
</script>
I want to send this to this route
Route::post('deletephoto','GamefarmsController@deletephoto');
on my Controller I want to do this just to test if its working
public function deletephoto()
{
dd($myvar);
}
Aucun commentaire:
Enregistrer un commentaire