ciao marco grazie della risposta devo fare per forza il return uso symfony

ho modificato cosi

codice:
 

var try = '';

$('.miaclasse').each(function(){
var idTry = $(this).attr('id');
var titleTry = $(this).attr('title');

if($('#' + idTry).length){
    try = try + idTry + '=' + titleTry + '&';
}
});

if(try){


$.ajax({
url: "/prova",
dataType: 'json',
type: 'POST',
data: try, //prova č un array
success: function(msg){
    var obj = msg;
    alert(obj.ciao);
        }

});
Codice PHP:

$req
= array();
        foreach (
$request->request->all() as $key => $value) {
            
           
$req[]= array("ciao"=>$this->controllaSessione($value));
        }


        
        return new 
Response(json_encode($req)); 

ma mi da ancora errore