您需要在AJAX调用的标头中包含CSRF令牌。试试这个:
在您的HTML
<head>块中:
<!-- This is one of the more common ways of accessing your CSRF token. --><meta name="csrf-token" content="{{ csrf_token() }}">对于您的AJAX电话:
var token = $('meta[name="csrf-token"]').attr('content');$.ajax({ type: "POST", url: baseLocalUrl, data: { html: $("#comment_area").text() }, // Added the CSRF token to the request header. header: {"X-CSRF-Token": token}, success: function(data) { alert("Success!"); }});最后,在中
app/filters.php,将CSRF过滤器更改为:
Route::filter('csrf', function(){ $token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token'); if (Session::token() != $token) { throw new IlluminateSessionTokenMismatchException; }});


