【发布时间】:2021-10-31 21:35:48
【问题描述】:
我在托管域上有 laravel 项目。现在我需要在另一个域上上传相同的项目。上传后我收到 csrf 不匹配错误。虽然它在以前的域上运行良好。错误如下所示: enter image description here
我在刀片模板和脚本文件中使用 csrf 指令。
@section('script')
<script>
$(document).ready(function(){
$.post('{{ route('home.section.featured') }}', {_token:'{{ csrf_token() }}'}, function(data){
$('#section_featured').html(data);
slickInit();
});
$.post('{{ route('home.section.best_selling') }}', {_token:'{{ csrf_token() }}'}, function(data){
$('#section_best_selling').html(data);
slickInit();
});
$.post('{{ route('home.section.home_categories') }}', {_token:'{{ csrf_token() }}'}, function(data){
$('#section_home_categories').html(data);
slickInit();
});
$.post('{{ route('home.section.best_sellers') }}', {_token:'{{ csrf_token() }}'}, function(data){
$('#section_best_sellers').html(data);
slickInit();
});
});
</script>
@endsection
【问题讨论】:
-
尝试清除缓存。
-
试过了,还是不行
-
如果可以,请不要将图片添加为链接。总有一天,该链接将停止工作,您的问题,无论它多么好,都将变得无用。将图形添加为图像或将代码添加为格式化文本。
标签: javascript php jquery laravel csrf-token