php - Why I obtain this exception when I try to handle an AJAX request with a Laravel controller method? -
i absolutly new in php , laravel , have following problem.
from view perform ajax post request via jquery, code:
jquery.ajax({ url: '/dosearch', type: 'post', datatype: 'json', //data: $form.serialize(), success: function(data){ console.info('ssssssssssiiii',data); }, error: function(data, b){ console.info('erroreeeeee'); } });
this post request handled simple controller method:
public function dosearch(){ echo 'searched'; }
that have return view searched string.
the problem obtaining error message:
http://localhost:8000/dosearch 500 (internal server error)
that create exception casauted tokenmismatchexception, in laravel stackrace can see this:
in verifycsrftoken.php line 68 @ verifycsrftoken->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in shareerrorsfromsession.php line 49 @ shareerrorsfromsession->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in startsession.php line 64 @ startsession->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in addqueuedcookiestoresponse.php line 37 @ addqueuedcookiestoresponse->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in encryptcookies.php line 59 @ encryptcookies->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in pipeline.php line 104 @ pipeline->then(object(closure)) in router.php line 644 @ router->runroutewithinstack(object(route), object(request)) in router.php line 618 @ router->dispatchtoroute(object(request)) in router.php line 596 @ router->dispatch(object(request)) in kernel.php line 267 @ kernel->illuminate\foundation\http\{closure}(object(request)) in pipeline.php line 53 @ pipeline->illuminate\routing\{closure}(object(request)) in checkformaintenancemode.php line 46 @ checkformaintenancemode->handle(object(request), object(closure)) in pipeline.php line 137 @ pipeline->illuminate\pipeline\{closure}(object(request)) in pipeline.php line 33 @ pipeline->illuminate\routing\{closure}(object(request)) in pipeline.php line 104 @ pipeline->then(object(closure)) in kernel.php line 149 @ kernel->sendrequestthroughrouter(object(request)) in kernel.php line 116 @ kernel->handle(object(request)) in index.php line 54 @ require_once('c:\xampp\htdocs\www.betrivius.it\application\public\index.php') in server.php line 21
why? problem? how can solve issue?
tnx
if coding .php page instead of .html page
try this:
<meta name="csrf-token" content="<?php echo csrf_token(); ?>">
instead:
<meta name="csrf-token" content="{{ csrf_token() }}">
it works me.
Comments
Post a Comment