laravel 5.2でjqueryとajaxを使用して編集ポストシステムを構築しています。私は私のブートストラップモーダルの変更を保存ボタンをクリックすると、次のエラーが表示されます。laravelでjqueryとajaxを使用した500の内部サーバエラー5.2
Error: POST http://localhost:8000/edit 500 (Internal Server Error)
send @ jquery-1.12.0.min.js:4
ajax @ jquery-1.12.0.min.js:4 (anonymous function) @ myplace.js:24
dispatch @ jquery-1.12.0.min.js:3
r.handle @ jquery-1.12.0.min.js:3
JSコード:ビューファイルに含ま
$('#modal-save').on('click' , function() {
$.ajax({
method : 'POST' ,
url : url ,
data: { body: $('#post-body').val(), postid: '' , _token: token }})
.done(function(msg) {
console.log(msg['message']);
});
});
:
<script>
var token='{{ Session::token() }}';
var url='{{ route('edit') }}' ;
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-1.2.1.min.js" ></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="src/js/myplace.js"></script>
'内部サーバーERROR'は、あなたがすべき、あなたを伝えるのサーバーの方法ですログファイルを読んでください。これは、便利なデバッグ情報を見つけることができる唯一の場所です。 – Oldskool
@Oldskool私のログファイル:http://laravel.io/bin/E31Qy –
CSRFトークンが無効であるようです。また、http://stackoverflow.com/questions/32738763/laravel-csrf-token-mismatch-for-ajax-post-request – Oldskool