I am getting a error as 419, for my update function. Something is not working properly; here is my ajax function in index.blade.php
$('#action1').click(function (){
var Ids = new Array();
var Names = new Array();
var Status = new Array();
if($(".selected").length){
$(".selected").each(function(){
Ids.push($(this).children(".id").html());
Names.push($(this).children(".company_name").html());
Status.push($(this).children(".status").html());
});
$.ajax({
url: 'update',
method:'POST',
dataType: 'json',
"id":Ids,
"company_name":Names,
"status":Status,
success: function(data){
$('#form1').html(data.success);
}
});
// alert(Ids);
// alert(Names);
// alert(Status);
}else{
alert("No row is selected.");
}
});
and this is my controller file:
public function update(Request $request)
{
$ids = $request->input('Ids');
$success_output = '';
$companies = companies::find($ids);
companies::whereIn('id',$ids);
$this->validate($request,
['company_name' => 'required',
'status' => 'required',
]);
$companies->company_name = $request->Names;
$companies->status = $request->Status;
$companies->save();
$success_output = '<div class="alert alert-success">Data Inserted</div>';
$output = array(
'errror' => $error_array,
'success' => $success_output
);
echo json_encode($output);
return redirect('/companies')->with('success','updated');
}
and this is my route function:
Route::post('update','AjaxController@update');
I want to update multiple rows at a time, but the update function may not working. can anyone suggest any solution?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire