<script>
$(document).ready(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#button-submit').on('click', function () {
var value = $('#input').val();
$('#chat-history-list').append('<li class="clearfix"><div class="message-data text-right"><span class="message-data-time">10:10 AM, Today</span><img src="../assets/images/xs/avatar2.jpg" alt="avatar"></div><div class="message other-message float-right">' + value + '</div></li>');
$.ajax({
url: "/chatsend",
type: 'POST',
data: {
'input': value
},
success: function (data) {
console.log("Başarıyla gönderildi. Sunucu cevabı:", data);
},
error: function (xhr, status, error) {
console.error("Bir hata oluştu:", error);
}
});
});
});
</script> Route: Route::post('/chatsend', [ChatController::class, 'chatsend'])->name('chatsend'); Fonksiyon : public function chatsend(Request $request)
{
dd($request->all());
} konsoldaki hata: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
chat:478 Bir hata oluştu: Internal Server Error
error @ chat:478