Answer the question
In order to leave comments, you need to log in
Why does Yii2 POST AJAX return 500 code but the response contains the correct data set?
It all started just recently, from scratch, as they say.
An AJAX POST request is sent from the browser, the request is processed correctly on the server side, but when data is returned from the action, the browser receives a 500 status despite the fact that the data also comes:
- i.imgur.com/fM1rv2o.png
- i.imgur.com/fp0dANe .png
The action returns data in JSON format:
<?php
//...
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$data = [...];
return $data;
// ...
?>
Answer the question
In order to leave comments, you need to log in
There was nothing in the logs, the problem was empirically identified: E_WARNING, which, for some reason, was not displayed anywhere until it was manually intercepted by hanging an error handler
set_error_handler(
function ($errno, $errstr) use($data) {
var_dump($errstr);
},
E_ALL
);
session_write_close(): open(/var/www/mysite/data/mod-tmp/sess_s8jm3ltvjbwermqsdr035rk6fp6, O_RDWR) failed: No such file or directory (2)"
string(162) "session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/www/mysite/data/mod-tmp)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question