pass array of numbers from ajax to controller

I know this is a popular topic and I’ve tried all of the solutions I could find already out there to no avail. I’ve used all the solutions included for this questions: Pass a List from javascript to controller. I’ve simplified my test to ridiculously simple. I get into the controller but my controller input param is {int[0]}. I confirmed my array data looks good in the JavaScript and ajax call.

Can anyone please tell me what I am missing?

JavaScript Code

var selectedIds = [];
selectedIds.push(565);
selectedIds.push(573);
selectedIds.push(571);
// selectedIds = [565, 573, 571]

$.ajax({
    type: "POST",
    traditional: true,
    dataType: "json",
    data: { "ids": JSON.stringify(selectedIds) },
    //data: { "ids": selectedIds},
    //data: { ids: selectedIds},
    url: "api/services/getbuildingsbyid",
    success: function (result) {
        return result;
    }
});

Controller Code

[HttpPost]
public bool GetBuildingsById(int[] ids)
{
    var lookAtIds = ids;     // {int[0]}
    return true;
}


Source: stackoverflow-javascript

Symfony2 cached controller won’t update

I’m quite new to PHP and have received some Symfony2 project to maintain. Now I’ve found out that when I update foo.html.twig, that page will not change until I perform the command console c:c -e prod. Until then the shown page will be foo.html_.twig (hence the underscore).

The problem is that I’ve changed a controller, let’s say BarController.php, but the new added value in that controller does not work in the .twig file, I think because the BarController_.php did not get updated with the clear cache command. What did I do wrong here?


Source: stackoverflow-php