Can you post the signature of your method that is supposed to accept this post?
Additionally I get the same error message, possibly for a different reason. My YSOD talked about the dictionary not containing a value for the non-nullable value.
The way I got the YSOD information was to put a breakpoint in the $.ajax function that handled an error return as follows:
<script type="text/javascript" language="javascript">
function SubmitAjax(url, message, successFunc, errorFunc) {
$.ajax({
type:'POST',
url:url,
data:message,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success:successFunc,
error:errorFunc
});
};
Then my errorFunc javascript is like this:
function(request, textStatus, errorThrown) {
$("#install").text("Error doing auto-installer search, proceed with ticket submissionn"
+request.statusText); }
Using IE I went to view menu -> script debugger -> break at next statement.
Then went to trigger the code that would launch my post. This usually took me somewhere deep inside jQuery’s library instead of where I wanted, because the select drop down opening triggered jQuery. So I hit StepOver, then the actual next line also would break, which was where I wanted to be. Then VS goes into client side(dynamic) mode for that page, and I put in a break on the $("#install")
line so I could see (using mouse over debugging) what was in request, textStatus, errorThrown. request. In request.ResponseText there was an html message where I saw:
<title>The parameters dictionary contains a null entry for parameter 'appId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ContentResult CheckForInstaller(Int32)' in 'HLIT_TicketingMVC.Controllers.TicketController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.<br>Parameter name: parameters</title>
so check all that, and post your controller method signature in case that’s part of the issue
Я из базы достаю записи определенного пользователя. При желании пользователь может оставить комментарий к записи. Есть кнопка «Добавить комментарий», при нажатии на которую вываливается textarea с кнопкой «Добавить». Вот все это хочу сделать ajaxom. Текст из textarea я получаю, но все это дело в бд не попадает.
Вот скрипт:
$('.comment').click(function(){
var id_advert = $(this).val();
//console.log(id_advert);
$(this).html("<textarea rows=10 cols=70 name='add_comment' class='add_comment' maxlengh='256' autofocus> </textarea><br><button type='submit' name='add' class='add'> Добавить сообщение</button>");
$.get('edit_advert',{comment:id_advert},function()
{
$('.add').click(function(){
var params = $('.add_comment').serialize();
console.log(params);
console.log($.post('add_comment',params));
});
});
});
Вот метод, который должен все это обрабатывать:
public function edit_advert(Request $request)
{
$id_advert = $_GET['comment'];
$id_client = Auth::user()->id;
$comment = $request->input('add_comment');
Adverts::add_comment($comment,$id_client,$id_advert);
}
Вьюшка:
<div class="panel-body">
@foreach ($remember_adverts_client as $advert)
<div class="table table-bordered">
Объявление добавлено <em> {{$advert->date}} </em> <br>
<strong>{{$advert->title}}</strong><br>
<strong>Тип недвижимости: </strong>{{$advert->type}}<br>
<strong>Количество комнат: </strong>{{$advert->quantity_room}}<br>
<strong>Город: </strong>{{$advert->city}}<br>
<strong> Описание: </strong> {{$advert->description}}<br>
<strong> Телефон: </strong>{{$advert->phone}}<br>
<!--<form action="edit_advert" method="GET"> -->
<button type="submit" value="{{$advert->id_realty}}" name="comment" class="comment"> Добавить комментарий</button>
<button type="submit" value="{{$advert->id_realty}}" name="cross"> Перечеркнуть </button>
<button type="submit" value="{{$advert->id_realty}}" name="lead">Обвести</button>
<button type="submit" value="{{$advert->id_realty}}" name="link">Поделиться ссылкой</button>
<!--</form> -->
@endforeach
И роут:
Route::get('edit_advert','ClientController@edit_advert');
Route::post('add_comment','ClientController@edit_advert')
В чем может быть проблема?
- Dec-23-2022
- Techsolutionstuff
-
Laravel
PHP
jQuery
In this article, we will see 500 internal server errors in laravel 9 ajax. Also, we can see how to solve or fixed laravel 9 500 internal server error ajax. If you are fetching 500 internal server errors in jquery ajax post request in laravel 9. Here we will let you know how to fix the ajax post 500 (Internal Server Error) request in laravel 9.
Laravel provides the best security using the csrf token. So, you have each time pass csrf_token when you fire ajax in the post, delete or put a request. You can generate csrf token using the csrf_token() helper of laravel 9. we will see you how to generate csrf_token and pass on each ajax request of jquery.
Also, you can add below meta tag and then you have to simply pass headers. It will automatically pass a token on each post request.
Add Meta tag:
<meta name="csrf-token" content="{{ csrf_token() }}">
Add JS Code:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
As above both codes, you have to write on each page. So, you can simply put it on the layout page or common header page.
You might also like :
- Read Also: Order By Query In Laravel 9 Example
- Read Also: Socialite Login with Facebook Account In Laravel 9
- Read Also: How To Solve The Page Expired 419 Error In Laravel
- Read Also: User Roles And Permissions Without Package Laravel 9
RECOMMENDED POSTS
FEATURE POSTS
In this tutorial you will learn about the Laravel 5 Fix Ajax Post 500 Internal Server Error and its application with practical example.
Many times while trying to submit form data using ajax you encounter 500 internal server error, in most of the cases this happens due to not adding csrf_token with form data or not setting X-CSRF-TOKEN request header with ajax form submit request. In this tutorial, I’ll show you how to add CSRF Meta and Ajax Headers properly to avoid internal server error.
Table Of Contents−
- Laravel 5 Fix Ajax Post 500 Internal Server Error
- Add CSRF Meta and Set Ajax Headers
Laravel comes with a security mechanism called csrf token. In Laravel, each of the request is attached a csrf_token that is validated before can be processed. In order to submit form data using ajax, we must have to incorporate csrf token with form data and set X-CSRF-TOKEN request header with ajax form submit request. This CSRF Token can generated using csrf_token() helper of laravel 5.
Add CSRF Token In Meta tag :-
<meta name=«csrf-token» content=«{{ csrf_token() }}»> |
Set CSRF Token In jQuery Ajax Header :-
$.ajaxSetup({ headers: { ‘X-CSRF-TOKEN’: $(‘meta[name=»csrf-token»]’).attr(‘content’) } }); |
In this tutorial we have learn about the Laravel 5 Fix Ajax Post 500 Internal Server Error and its application with practical example. I hope you will like this tutorial.

Hi Guys,
If you are fetching 500 internal server error in jquery ajax post request in laravel 8, then you are a right place. Here i will let you know how to fixed Ajax Post 500 (Internal Server Error) request in laravel 8.
If you know well laravel then you know about csrf token, laravel provide best security using csrf token. So you have each time pass csrf_token when you fire ajax post, delete or put request. You can generate csrf token using csrf_token() helper of laravel 8.
So, Here i will see you how to generate csrf_token and pass on each ajax request of jquery. So let’s you have to add bellow meta tag and then you have to simple pass headers. It will automatically pass token on each post request.
Add Meta tag:
<meta name="csrf-token" content="{{ csrf_token() }}">
Add JS Code:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
As above both code, you have to write in each page so you can simply put in layout page.
I hope it help you…
#Laravel 8
#Laravel 7
#Laravel
#Laravel 6
✌️ Like this article? Follow me on Twitter and Facebook. You can also subscribe to RSS Feed.