Reputation: 123
I am using Laravel 5.6.33 and when wanting to send the information with the method PUT it is impossible for me, the update function does not receive anything.
this is my javascript:
$("#SaveArea").on("click",function(e){
event.preventDefault();
var token = $("#token").val();
$.ajax({
url: "/areas/{{ $area->AreaID }}",
headers:{'X-CSRF-TOKEN':token},
contentType: false,
processData: false,
data: {"name":"alex"},
type: 'put',
beforeSend: function () {
// alert("akus")
},
success: function (response) {
console.log(response)
// swal(response['mensaje'],'', "success");
}
});
});
form data:
<form class="form-group" method="POST" action="/areas/{{ $area->AreaID }}" autocomplete="off" id="FormArea">
@method('PUT')
@csrf
update function:
public function update(Request $request, Area $area)
{
return $request->all() ;
web.php
// Areas
Route::resource('/areas','AreasController');
Route::post('/areas/store','AreasController@store');
Route::get('/areas','AreasController@getAreas');
Route::get('/area/new',function(){
return view("rrh.new_area");});
Upvotes: 0
Views: 69
Reputation: 5386
type can only be GET or POST
Remove contentType: false, processData: false
Change: event to e
Upvotes: 1