【发布时间】:2016-11-26 04:59:24
【问题描述】:
我正在 laravel 5.2 中使用 jquery 和 ajax 构建编辑帖子系统。当我在我的引导模式中单击保存更改按钮时,会显示以下错误:
错误:POST http://localhost:8000/edit 500(内部服务器错误)
发送@jquery-1.12.0.min.js:4
ajax@jquery-1.12.0.min.js:4(匿名函数)@myplace.js:24
调度@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>
【问题讨论】:
-
Internal Server Error是您的服务器告诉您应该阅读它的日志文件的方式。这是您唯一可以找到有用的调试信息的地方。 -
@Oldskool 我的日志文件:laravel.io/bin/E31Qy
-
看起来您的 CSRF 令牌无效。另见stackoverflow.com/questions/32738763/…
-
@Oldskool ya ty ,但我已经实现了该方法但同样的错误。
标签: javascript jquery ajax twitter-bootstrap laravel-5.2