我正在使用带有 AJAX 的 Laravel Delete 方法来删除一个问题,当它删除它时,localhost/upwork_project/questions当我单击任何问题的“阅读更多”按钮时,它会包含所有问题,URL 看起来像这样localhost/upwork_project/questions/questions/my-question-slug,并且由于双重参数而导致 404 未找到错误questions/questions但是当我创建问题或编辑它不添加任何额外的参数并且一切正常,但是当我删除任何问题时,它会进入问题的索引页面并执行此操作。我的 AJAX 请求:
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: $(this).attr('action'),
type: 'DELETE',
success: function(data) {
if (data == 'question_deleted') {
window.location.href = './';
}
else if (data == 'question_deletion_error') {
$('.invalid-feedback').fadeIn('fast');
$('.question_deletion_error').html('Ops! there is an error.')
}
},
});
我的阅读更多按钮代码是:
<a href="questions/{{ $question->question_slug }}" class="btn btn-primary btn-sm">Continue Reading</a>