I have the following function that makes an ajax call to update data in my table:
$("#editar").click(function(){
if($idfila!=null){
ruta=url_base+"/patron/"+$idfila;
var formData = new FormData($("#formulario_datos")[0]);
formData.append("_token",'{{csrf_token()}}');
tipo='PATCH';
myajax(ruta,tipo,formData,function(resp,t){
if(t=='success'){
toastr.success(resp.msn);
limpiar();
$("#table-contenido").append($html);
$('.datatables').DataTable();
}else{
toastr.error(resp.msn);
toastr.error(resp.responseJSON.message);
}
});
}else{
toastr.warning("Seleccione un elemento primero");
}
botones(false,true,true,true,true);
});
The myajax
function is as follows:
function myajax(url,tipo,datos,callback){
$.ajax({
url: url,
type: tipo,
data: datos,
contentType:false,
processData:false,
success:function(data){
callback(data,'success');
},
error:function(error){
callback(error,'error');
}
});
}
and my form is as follows:
<form method="POST" id="formulario_datos" accept-charset="UTF-8">
{{csrf_field()}}
<div class="form-group">
{!!Form::label('nombre','NOMBRE: ', ['class'=>'col-sm-3 col-md-3 col-lg-3 control-label input-sm'])!!}
<div class="col-sm-9 col-md-9 col-lg-9">
{!!Form::text('nombre',null, ['id'=>'nombre', 'class'=>'input-sm', 'required' => 'required','disabled'=>'true'])!!}
</div>
</div>
<div class="form-group">
{!!Form::label('SIMBOLO','SIMBOLO: ', ['class'=>'col-sm-3 col-md-3 col-lg-3 control-label input-sm'])!!}
<div class="col-sm-9 col-md-9 col-lg-9">
{!!Form::text('simbolo',null, ['id'=>'simbolo', 'class'=>'input-sm', 'required' => 'required','disabled'=>'true'])!!}
</div>
</div>
<div class="form-group">
@include("buttons")
</div>
</form>
When I try to update the data, that is, make the call ajax
, the following error returns:
PATCH link 419 (unknown status)
entering clearly the error I found:
exception: "Symfony \ Component \ HttpKernel \ Exception \ HttpException"
file: "C: \ xampp \ htdocs \ SalesLight \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Exceptions \ Handler.php"
line: 203
message: ""
I have read other cases in which they say that they would lack the _token
but if they look at my form
I have it included.