i make a crud in laravel using ajax, but i have problem there are can't response my script.
this is my form:
{!!Form::Open()!!}
{!!Form::text('judul',null,['id'=>'agenda', 'class'=>'form-control','placeholder'=>'Judul'])!!}
{!!link_to('#',$tittle='Submit', $attributes = ['id' => 'okModal', 'class'=>'btn btn-primary'], $secure = null) !!}
{!!Form::Close()!!}
and this is my script.js
$("#okModal").click(function(){
var datas = $("#agenda").val();
var route = "/agenda";
var token = $("#token").val();
$.ajax({
url: route,
headers : {'X-CSRF-TOKEN':token},
type: 'POST',
dataType: 'json',
data: {agenda :datas}
});
});
when i run and view the inspect manager in chrome browser, is not response the /agenda . whereas we know my button link to route:/agenda.
this is my controller :
public function store(Request $request)
{
if($request -> ajax()){
return response()->json([
"pesan" => $request->all()
]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire