Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony Request - get Internal Server Error

I try to make an Ajax Post Request to a controller in my Project. I made a var_dump() of the $request and it shows me the full Request object including my sent data. If I try to access the data or make var_dump($request->request); (For the POST-Data) I get a Internal Server Error 500. I can't figure out what I'm doing wrong.

View:

$.ajax({
    type: "post",        
    url: "/symfony/web/app_dev.php/setliste/{{entity.id}}/update",
    data: { dataArray : dataArray },
    error: function(x, status, error) {
        alert(status+error);
        console.log(x);
    }
}).done(function(msg){
    console.log(msg);
});

Controller:

public function updateAction(Request $request, $id) {
    $test = $request;
    var_dump($test);
}

Alex

like image 721
alex Avatar asked May 09 '26 04:05

alex


1 Answers

A controller action must have a return statement which contains a Response.

To solve this problem, change your code to :

public function updateAction(Request $request, $id) {
    $test = $request;

    return new \Symfony\Component\HttpFoundation\Response(var_dump($test));
}
like image 77
chalasr Avatar answered May 10 '26 18:05

chalasr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!