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
When ever I am doing an ajax request with jquery I always get an error 500 return,
I am posting to the following URL
http://localhost/domain/index.php/my_profile/interests_music
using this javascript,
$("#add").click(function(e){
//set some process variables, we need to get the forms action,
//and any post data it is sending appending isAjax into the params
//gives us a point in the controller to gracefully check for ajax.
var action = $(this).parent('form').attr('action');
var formData = $(this).parent('form').serialize()+"&isAjax=1";
$.ajax({
type: "POST",
url: action,
data: formData
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
e.preventDefault();
});
The params that are being sent are,
music=Savage Garden&isAjax=1
And the PHP method the ajax is requesting looks like this,
public function interests_music()
{
if($this->input->post('music'))
{
$this->rest->initialize(array('server' => 'https://www.googleapis.com/freebase/v1'));
$response = $this->rest->get('mqlread?query={"type":"/music/artist","name":"' . urlencode($this->input->post('music')) . '","id":[]}');
$data['image'] = 'https://usercontent.googleapis.com/freebase/v1/image'.$response->result->id[0].'?mode=fillcrop&maxwidth=80&maxheight=80';
$data['category'] = 'music';
$data['user_id'] = $this->session->userdata('id');
$data['name'] = $this->input->post('music', TRUE);
$this->profile_model->add_interest($data);
Events::trigger('interests_music');
Events::trigger('badge_stagediver');
if($this->input->post('isAjax') == 1)
{
echo json_endcode($data);
$this->_buttons();
}
redirect('my_profile/interests');
}
else
{
show_404();
}
}
Am I missing something, is this a common problem?
Я из базы достаю записи определенного пользователя. При желании пользователь может оставить комментарий к записи. Есть кнопка «Добавить комментарий», при нажатии на которую вываливается 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')
В чем может быть проблема?
Isn’t it annoying to see the “drupal ajax error 500” error plaguing your website?
This is one of the common Drupal errors you will encounter while running a website.
This error occurs due to many reasons that include insufficient memory, bad permissions, and so on.
Here at Bobcares, we often receive requests to resolve drupal errors as a part of our Server Management Services for web hosts and online service providers.
Today, let’s discuss the different causes for this error to occur and see how our Support Engineers fix it.
Different causes for drupal ajax error 500 to occur
Let’s now look into the different reasons that cause this error.
1. Insufficient memory
If there isn’t sufficient memory to run the process it causes this error to occur.
So it is better to set a greater memory in the php.ini file. We can also set this memory limit in the .htaccess file as well.
2. Bad permissions
Bad permissions are one of the most common reasons that cause errors in the website.
Even, for drupal ajax error 500 to occur, improper permissions also can be one of the reasons.
3. Broken modules
Customers do enable modules on the website for better performance. In case, if these modules break then it will create a problem without the insight of the website owner.
So, it is best to uninstall the module and then get it re-installed and check if it was causing an error.
How we fix this drupal ajax error 500?
One of our customers was trying to install Drupal Open Enterprise and received an error message as shown below:
Let’s now see how our Support Engineers fix this error.
First, we started to troubleshoot the error by increasing the PHP parameters. We increase the memory_limit in the php.ini file.
Here are the parameters that we set in the php.ini file.
max_execution_time = 180
max_input_time = 180
max_input_nesting_level = 300
memory_limit = 512M
And then we added the below line in .htaccess file
php_value auto_append_file none
Next, we verified the permission of sites/default/settings.php and sites/default folder.
Browsing to the folder where drupal was extracted we made a copy of sites/default/default.settings.php to sites/default/settings.php
$ cp sites/default/default.settings.php sites/default/settings.php
And then ensured permissions were set correctly on both the paths by running the command.
$ chmod a+w sites/default/settings.php
$ chmod a+w sites/default
After the changes, we were able to install drupal without any error.
[Need any assistance in fixing drupal error? – We’ll are always there to help you]
Conclusion
In short, the drupal ajax error 500 occurs due to various reasons like insufficient memory, bad permissions, and broken modules. Today, we discussed the different reasons that cause this error and saw how our Support Engineers fix it.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
var google_conversion_label = «owonCMyG5nEQ0aD71QM»;
- 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

